From c40cb951a96d0740d820f73df6f9804990b4dc35 Mon Sep 17 00:00:00 2001 From: NIKUNJ LALITKUMAR HUDKA Date: Fri, 18 Oct 2024 18:57:42 -0300 Subject: [PATCH] chore: remove used code and solve eslint error Signed-off-by: NIKUNJ LALITKUMAR HUDKA --- .../urlReader/lib/AzureBlobStorageUrlReader.ts | 18 +++--------------- .../DefaultAzureCredentialsManager.test.ts | 2 -- .../AzureBlobStorageEntityProvider.test.ts | 16 +++------------- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/packages/backend-defaults/src/entrypoints/urlReader/lib/AzureBlobStorageUrlReader.ts b/packages/backend-defaults/src/entrypoints/urlReader/lib/AzureBlobStorageUrlReader.ts index f0c7e2570e..039af6d3ed 100644 --- a/packages/backend-defaults/src/entrypoints/urlReader/lib/AzureBlobStorageUrlReader.ts +++ b/packages/backend-defaults/src/entrypoints/urlReader/lib/AzureBlobStorageUrlReader.ts @@ -39,10 +39,7 @@ import { UrlReaderServiceSearchResponse, } from '@backstage/backend-plugin-api'; -export function parseUrl( - url: string, - config: AzureBlobStorageIntergation, -): { path: string; container: string } { +export function parseUrl(url: string): { path: string; container: string } { const parsedUrl = new URL(url); const pathSegments = parsedUrl.pathname.split('/').filter(Boolean); @@ -138,7 +135,7 @@ export class AzureBlobStorageUrlReader implements UrlReaderService { const { etag, lastModifiedAfter } = options ?? {}; try { - const { path, container } = parseUrl(url, this.integration); + const { path, container } = parseUrl(url); const containerClient = await this.createContainerClient(container); const blobClient = containerClient.getBlobClient(path); @@ -184,7 +181,7 @@ export class AzureBlobStorageUrlReader implements UrlReaderService { options?: UrlReaderServiceReadTreeOptions, ): Promise { try { - const { path, container } = parseUrl(url, this.integration); + const { path, container } = parseUrl(url); const containerClient = await this.createContainerClient(container); @@ -230,15 +227,6 @@ export class AzureBlobStorageUrlReader implements UrlReaderService { )}}`; } - private parseUrl(url: string): { path: string } { - const parsedUrl = new URL(url); - const path = parsedUrl.pathname.substring( - parsedUrl.pathname.lastIndexOf('/') + 1, - ); - - return { path }; - } - private async retrieveAzureBlobData(stream: Readable): Promise { return new Promise((resolve, reject) => { try { diff --git a/packages/integration/src/azureBlobStorage/DefaultAzureCredentialsManager.test.ts b/packages/integration/src/azureBlobStorage/DefaultAzureCredentialsManager.test.ts index 6272a68d13..d8e8be2919 100644 --- a/packages/integration/src/azureBlobStorage/DefaultAzureCredentialsManager.test.ts +++ b/packages/integration/src/azureBlobStorage/DefaultAzureCredentialsManager.test.ts @@ -18,9 +18,7 @@ import { AccessToken, ClientSecretCredential, DefaultAzureCredential, - TokenCredential, } from '@azure/identity'; -import { AzureBlobStorageIntegrationConfig } from './config'; import { ScmIntegrationRegistry } from '../registry'; import { ConfigReader } from '@backstage/config'; import { DefaultAzureCredentialsManager } from './DefaultAzureCredentialsProvider'; diff --git a/plugins/catalog-backend-module-azure/src/providers/AzureBlobStorageEntityProvider.test.ts b/plugins/catalog-backend-module-azure/src/providers/AzureBlobStorageEntityProvider.test.ts index 5ec50754c0..515d2ee7d0 100644 --- a/plugins/catalog-backend-module-azure/src/providers/AzureBlobStorageEntityProvider.test.ts +++ b/plugins/catalog-backend-module-azure/src/providers/AzureBlobStorageEntityProvider.test.ts @@ -48,6 +48,7 @@ jest.mock('@azure/storage-blob', () => { BlobServiceClient: jest.fn().mockImplementation(() => ({ url: 'https://myaccount.blob.core.windows.net/', getContainerClient: jest.fn().mockImplementation(() => ({ + // eslint-disable-next-line func-names listBlobsFlat: jest.fn(async function* () { yield* createBlobList(blobs); }), @@ -65,7 +66,6 @@ describe('AzureBlobStorageEntityProvider', () => { providerId: string, providerConfig: object, expectedBaseUrl: string, - names: Record, integrationConfig?: object, scheduleInConfig?: boolean, ) => { @@ -151,6 +151,7 @@ describe('AzureBlobStorageEntityProvider', () => { }); }; + // eslint-disable-next-line jest/expect-expect it('apply full update on scheduled execution', async () => { return expectMutation( 'staticContainer', @@ -158,18 +159,13 @@ describe('AzureBlobStorageEntityProvider', () => { containerName, }, 'https://myaccount.blob.core.windows.net/container-1/', - { - 'key1.yaml': 'generated-8ece85ad90200c6577b99f553dcbedde05fa34bb', - 'key2.yaml': 'generated-6b54c6aaa44696f5e91ce0f54fb27bf837549d11', - 'key3.yaml': 'generated-88c703cf1aa66913db4033b029adc0b174574646', - 'key4.yaml': 'generated-2b7e068bb4ec818c14f179a1e721843fc2dbc5f9', - }, { accountName: 'myaccount', }, ); }); + // eslint-disable-next-line jest/expect-expect it('apply full update no prefix', async () => { return expectMutation( 'staticContainerNoPrefix', @@ -181,12 +177,6 @@ describe('AzureBlobStorageEntityProvider', () => { }, }, 'https://myaccount.blob.core.windows.net/container-1/', - { - 'key1.yaml': 'generated-8ece85ad90200c6577b99f553dcbedde05fa34bb', - 'key2.yaml': 'generated-6b54c6aaa44696f5e91ce0f54fb27bf837549d11', - 'key3.yaml': 'generated-88c703cf1aa66913db4033b029adc0b174574646', - 'key4.yaml': 'generated-2b7e068bb4ec818c14f179a1e721843fc2dbc5f9', - }, { host: 'blob.core.windows.net', accountName: 'myaccount',