diff --git a/plugins/catalog-backend/src/ingestion/LocationReaders.ts b/plugins/catalog-backend/src/ingestion/LocationReaders.ts index a217e07f1d..b911a7a50d 100644 --- a/plugins/catalog-backend/src/ingestion/LocationReaders.ts +++ b/plugins/catalog-backend/src/ingestion/LocationReaders.ts @@ -88,7 +88,12 @@ export class LocationReaders implements LocationReader { new BitbucketApiReaderProcessor(config), new AzureApiReaderProcessor(config), GithubOrgReaderProcessor.fromConfig(config), - options.reader ? new UrlReaderProcessor(options.reader) : [], + options.reader + ? new UrlReaderProcessor({ + reader: options.reader, + logger: options.logger, + }) + : [], new YamlProcessor(), PlaceholderProcessor.default(), new CodeOwnersProcessor(), diff --git a/plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts index 94a7b01336..2bc05bf1cb 100644 --- a/plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts +++ b/plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts @@ -14,25 +14,47 @@ * limitations under the License. */ +import { Logger } from 'winston'; import { UrlReader } from '@backstage/backend-common'; import { LocationSpec } from '@backstage/catalog-model'; import * as result from './results'; import { LocationProcessor, LocationProcessorEmit } from './types'; +// TODO(Rugvip): Added for backwards compatibility when moving to UrlReader, this +// can be removed in a bit +const deprecatedTypes = [ + 'github', + 'github/api', + 'bitbucket/api', + 'gitlab/api', + 'azure/api', +]; + +type Options = { + reader: UrlReader; + logger: Logger; +}; + export class UrlReaderProcessor implements LocationProcessor { - constructor(private readonly reader: UrlReader) {} + constructor(private readonly options: Options) {} async readLocation( location: LocationSpec, optional: boolean, emit: LocationProcessorEmit, ): Promise { - if (location.type !== 'url') { + if (deprecatedTypes.includes(location.type)) { + // TODO(Rugvip): Let's not enable this warning yet, as we want to move over the example YAMLs + // in this repo to use the 'url' type first. + // this.options.logger.warn( + // `Using deprecated location type '${location.type}' for '${location.target}', use 'url' instead`, + // ); + } else if (location.type !== 'url') { return false; } try { - const data = await this.reader.read(location.target); + const data = await this.options.reader.read(location.target); emit(result.data(location, data)); } catch (error) { const message = `Unable to read ${location.type}, ${error}`;