diff --git a/plugins/catalog-backend-module-github/src/analyzers/GitHubLocationAnalyzer.ts b/plugins/catalog-backend-module-github/src/analyzers/GitHubLocationAnalyzer.ts index 085f82de49..d1112d2cc0 100644 --- a/plugins/catalog-backend-module-github/src/analyzers/GitHubLocationAnalyzer.ts +++ b/plugins/catalog-backend-module-github/src/analyzers/GitHubLocationAnalyzer.ts @@ -20,7 +20,6 @@ import { Octokit } from '@octokit/rest'; import { trimEnd } from 'lodash'; import parseGitUrl from 'git-url-parse'; import { - AnalyzeLocationExistingEntity, AnalyzeOptions, ScmLocationAnalyzer, } from '@backstage/plugin-catalog-backend'; @@ -41,8 +40,10 @@ export class GitHubLocationAnalyzer implements ScmLocationAnalyzer { this.config = options.config; this.catalogClient = new CatalogClient({ discoveryApi: options.discovery }); } - getIntegrationType() { - return 'github'; + supports(url: string) { + const integrations = ScmIntegrations.fromConfig(this.config); + const integration = integrations.byUrl(url); + return integration?.type === 'github'; } async analyze({ url, catalogFilename }: AnalyzeOptions) { const { owner, name: repo } = parseGitUrl(url); diff --git a/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts b/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts index b863f00f2c..3dc08a81c3 100644 --- a/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts +++ b/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts @@ -63,8 +63,8 @@ export class RepoLocationAnalyzer implements LocationAnalyzer { break; } - const analyzer = this.analyzers.find( - a => a.getIntegrationType() === integration?.type, + const analyzer = this.analyzers.find(a => + a.supports(request.location.target), ); if (analyzer) { const analyzerResult = await analyzer.analyze({ diff --git a/plugins/catalog-backend/src/ingestion/types.ts b/plugins/catalog-backend/src/ingestion/types.ts index 40b4574f78..c5237af6d3 100644 --- a/plugins/catalog-backend/src/ingestion/types.ts +++ b/plugins/catalog-backend/src/ingestion/types.ts @@ -108,8 +108,8 @@ export type AnalyzeOptions = { /** @public */ export type ScmLocationAnalyzer = { - /** The integration type this location analyzer can work with */ - getIntegrationType(): string; + /** The method that decides if this analyzer can work with the provided url */ + supports(url: string): boolean; /** This function can return an array of already existing entities */ analyze(options: AnalyzeOptions): Promise<{ existing: AnalyzeLocationExistingEntity[];