catalog-backend: Require impl of getProcessorName in CatalogProcessor
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': minor
|
||||
---
|
||||
|
||||
Updated all processors to implement `getProcessorName`.
|
||||
|
||||
**BREAKING**: The `CatalogProcessor` interface now require that the `CatalogProcessor` class implements `getProcessorName()`.
|
||||
The processor name has previously defaulted processor class name. It's therefore _recommended_ to keep your return the same name as the class name if you did not implement this method previously.
|
||||
|
||||
For example:
|
||||
|
||||
```ts
|
||||
class CustomProcessor implements CatalogProcessor {
|
||||
getProcessorName() {
|
||||
// Use the same name as the class name if this method was not previously implemented.
|
||||
return 'CustomProcessor';
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-ldap': patch
|
||||
'@backstage/plugin-catalog-backend-module-msgraph': patch
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Implemented required `getProcessorName` method for catalog processor.
|
||||
@@ -472,8 +472,8 @@ type CacheItem = {
|
||||
export class SystemXReaderProcessor implements CatalogProcessor {
|
||||
constructor(private readonly reader: UrlReader) {}
|
||||
|
||||
// It's recommended to give the processor a unique name.
|
||||
getProcessorName() {
|
||||
// The processor name must be unique.
|
||||
return 'system-x-processor';
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,8 @@ export class LdapOrgReaderProcessor implements CatalogProcessor {
|
||||
},
|
||||
): LdapOrgReaderProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
|
||||
@@ -69,6 +69,10 @@ export class LdapOrgReaderProcessor implements CatalogProcessor {
|
||||
this.userTransformer = options.userTransformer;
|
||||
}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'LdapOrgReaderProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
|
||||
@@ -134,6 +134,8 @@ export class MicrosoftGraphOrgReaderProcessor implements CatalogProcessor {
|
||||
},
|
||||
): MicrosoftGraphOrgReaderProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
|
||||
+3
@@ -73,6 +73,9 @@ export class MicrosoftGraphOrgReaderProcessor implements CatalogProcessor {
|
||||
this.groupTransformer = options.groupTransformer;
|
||||
this.organizationTransformer = options.organizationTransformer;
|
||||
}
|
||||
getProcessorName(): string {
|
||||
return 'MicrosoftGraphOrgReaderProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
|
||||
@@ -92,6 +92,8 @@ export class AnnotateLocationEntityProcessor implements CatalogProcessor {
|
||||
// Warning: (ae-forgotten-export) The symbol "Options" needs to be exported by the entry point index.d.ts
|
||||
constructor(options: Options);
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
preProcessEntity(
|
||||
entity: Entity,
|
||||
location: LocationSpec,
|
||||
@@ -108,6 +110,8 @@ export class AnnotateScmSlugEntityProcessor implements CatalogProcessor {
|
||||
// (undocumented)
|
||||
static fromConfig(config: Config): AnnotateScmSlugEntityProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
|
||||
}
|
||||
|
||||
@@ -134,6 +138,8 @@ export class AwsOrganizationCloudAccountProcessor implements CatalogProcessor {
|
||||
// (undocumented)
|
||||
getAwsAccounts(): Promise<Account[]>;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
logger: Logger_2;
|
||||
// (undocumented)
|
||||
mapAccountToComponent(account: Account): ResourceEntityV1alpha1;
|
||||
@@ -164,6 +170,8 @@ export type AwsOrganizationProviderConfig = {
|
||||
export class AwsS3DiscoveryProcessor implements CatalogProcessor {
|
||||
constructor(reader: UrlReader);
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
optional: boolean,
|
||||
@@ -188,6 +196,8 @@ export class AzureDevOpsDiscoveryProcessor implements CatalogProcessor {
|
||||
},
|
||||
): AzureDevOpsDiscoveryProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
@@ -213,6 +223,8 @@ export class BitbucketDiscoveryProcessor implements CatalogProcessor {
|
||||
},
|
||||
): BitbucketDiscoveryProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
@@ -233,6 +245,8 @@ export type BitbucketRepositoryParser = (options: {
|
||||
//
|
||||
// @public (undocumented)
|
||||
export class BuiltinKindsEntityProcessor implements CatalogProcessor {
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
postProcessEntity(
|
||||
entity: Entity,
|
||||
@@ -352,7 +366,7 @@ export interface CatalogProcessingOrchestrator {
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type CatalogProcessor = {
|
||||
getProcessorName?(): string;
|
||||
getProcessorName(): string;
|
||||
readLocation?(
|
||||
location: LocationSpec,
|
||||
optional: boolean,
|
||||
@@ -479,6 +493,8 @@ export class CodeOwnersProcessor implements CatalogProcessor {
|
||||
},
|
||||
): CodeOwnersProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
|
||||
}
|
||||
|
||||
@@ -730,6 +746,8 @@ export type EntityProviderMutation =
|
||||
//
|
||||
// @public (undocumented)
|
||||
export class FileReaderProcessor implements CatalogProcessor {
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
@@ -765,6 +783,8 @@ export class GithubDiscoveryProcessor implements CatalogProcessor {
|
||||
},
|
||||
): GithubDiscoveryProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
@@ -789,6 +809,8 @@ export class GithubMultiOrgReaderProcessor implements CatalogProcessor {
|
||||
},
|
||||
): GithubMultiOrgReaderProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
@@ -843,6 +865,8 @@ export class GithubOrgReaderProcessor implements CatalogProcessor {
|
||||
},
|
||||
): GithubOrgReaderProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
@@ -862,6 +886,8 @@ export class GitLabDiscoveryProcessor implements CatalogProcessor {
|
||||
},
|
||||
): GitLabDiscoveryProcessor;
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
@@ -902,6 +928,8 @@ export type LocationAnalyzer = {
|
||||
export class LocationEntityProcessor implements CatalogProcessor {
|
||||
constructor(options: LocationEntityProcessorOptions);
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
postProcessEntity(
|
||||
entity: Entity,
|
||||
location: LocationSpec,
|
||||
@@ -1026,6 +1054,8 @@ export const permissionRules: {
|
||||
export class PlaceholderProcessor implements CatalogProcessor {
|
||||
constructor(options: PlaceholderProcessorOptions);
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ type Options = {
|
||||
export class AnnotateLocationEntityProcessor implements CatalogProcessor {
|
||||
constructor(private readonly options: Options) {}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'AnnotateLocationEntityProcessor';
|
||||
}
|
||||
|
||||
async preProcessEntity(
|
||||
entity: Entity,
|
||||
location: LocationSpec,
|
||||
|
||||
@@ -30,6 +30,10 @@ export class AnnotateScmSlugEntityProcessor implements CatalogProcessor {
|
||||
private readonly opts: { scmIntegrationRegistry: ScmIntegrationRegistry },
|
||||
) {}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'AnnotateScmSlugEntityProcessor';
|
||||
}
|
||||
|
||||
static fromConfig(config: Config): AnnotateScmSlugEntityProcessor {
|
||||
return new AnnotateScmSlugEntityProcessor({
|
||||
scmIntegrationRegistry: ScmIntegrations.fromConfig(config),
|
||||
|
||||
+3
@@ -81,6 +81,9 @@ export class AwsOrganizationCloudAccountProcessor implements CatalogProcessor {
|
||||
region: AWS_ORGANIZATION_REGION,
|
||||
}); // Only available in us-east-1
|
||||
}
|
||||
getProcessorName(): string {
|
||||
return 'AwsOrganizationCloudAccountProcessor';
|
||||
}
|
||||
|
||||
normalizeName(name: string): string {
|
||||
return name
|
||||
|
||||
@@ -28,6 +28,10 @@ import {
|
||||
export class AwsS3DiscoveryProcessor implements CatalogProcessor {
|
||||
constructor(private readonly reader: UrlReader) {}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'AwsS3DiscoveryProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
optional: boolean,
|
||||
|
||||
@@ -60,6 +60,10 @@ export class AzureDevOpsDiscoveryProcessor implements CatalogProcessor {
|
||||
this.logger = options.logger;
|
||||
}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'AzureDevOpsDiscoveryProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
|
||||
@@ -64,6 +64,10 @@ export class BitbucketDiscoveryProcessor implements CatalogProcessor {
|
||||
this.logger = options.logger;
|
||||
}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'BitbucketDiscoveryProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
|
||||
@@ -69,6 +69,10 @@ export class BuiltinKindsEntityProcessor implements CatalogProcessor {
|
||||
domainEntityV1alpha1Validator,
|
||||
];
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'BuiltinKindsEntityProcessor';
|
||||
}
|
||||
|
||||
async validateEntityKind(entity: Entity): Promise<boolean> {
|
||||
for (const validator of this.validators) {
|
||||
const results = await validator.check(entity);
|
||||
|
||||
@@ -64,6 +64,10 @@ export class CodeOwnersProcessor implements CatalogProcessor {
|
||||
this.reader = options.reader;
|
||||
}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'CodeOwnersProcessor';
|
||||
}
|
||||
|
||||
async preProcessEntity(
|
||||
entity: Entity,
|
||||
location: LocationSpec,
|
||||
|
||||
@@ -29,6 +29,10 @@ import {
|
||||
const glob = promisify(g);
|
||||
|
||||
export class FileReaderProcessor implements CatalogProcessor {
|
||||
getProcessorName(): string {
|
||||
return 'FileReaderProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
optional: boolean,
|
||||
|
||||
@@ -60,6 +60,10 @@ export class GitLabDiscoveryProcessor implements CatalogProcessor {
|
||||
this.logger = options.logger;
|
||||
}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'GitLabDiscoveryProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
_optional: boolean,
|
||||
|
||||
@@ -73,6 +73,9 @@ export class GithubDiscoveryProcessor implements CatalogProcessor {
|
||||
options.githubCredentialsProvider ||
|
||||
DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);
|
||||
}
|
||||
getProcessorName(): string {
|
||||
return 'GithubDiscoveryProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
|
||||
@@ -78,6 +78,9 @@ export class GithubMultiOrgReaderProcessor implements CatalogProcessor {
|
||||
options.githubCredentialsProvider ||
|
||||
DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);
|
||||
}
|
||||
getProcessorName(): string {
|
||||
return 'GithubMultiOrgReaderProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
|
||||
@@ -70,6 +70,9 @@ export class GithubOrgReaderProcessor implements CatalogProcessor {
|
||||
DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);
|
||||
this.logger = options.logger;
|
||||
}
|
||||
getProcessorName(): string {
|
||||
return 'GithubOrgReaderProcessor';
|
||||
}
|
||||
|
||||
async readLocation(
|
||||
location: LocationSpec,
|
||||
|
||||
@@ -45,6 +45,10 @@ export type LocationEntityProcessorOptions = {
|
||||
export class LocationEntityProcessor implements CatalogProcessor {
|
||||
constructor(private readonly options: LocationEntityProcessorOptions) {}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'LocationEntityProcessor';
|
||||
}
|
||||
|
||||
async postProcessEntity(
|
||||
entity: Entity,
|
||||
location: LocationSpec,
|
||||
|
||||
@@ -52,6 +52,10 @@ export type PlaceholderProcessorOptions = {
|
||||
export class PlaceholderProcessor implements CatalogProcessor {
|
||||
constructor(private readonly options: PlaceholderProcessorOptions) {}
|
||||
|
||||
getProcessorName(): string {
|
||||
return 'PlaceholderProcessor';
|
||||
}
|
||||
|
||||
async preProcessEntity(
|
||||
entity: Entity,
|
||||
location: LocationSpec,
|
||||
|
||||
@@ -24,9 +24,8 @@ import { JsonValue } from '@backstage/types';
|
||||
export type CatalogProcessor = {
|
||||
/**
|
||||
* A unique identifier for the Catalog Processor.
|
||||
* It's strongly recommended to implement getProcessorName as this method will be required in the future.
|
||||
*/
|
||||
getProcessorName?(): string;
|
||||
getProcessorName(): string;
|
||||
|
||||
/**
|
||||
* Reads the contents of a location.
|
||||
|
||||
@@ -208,6 +208,7 @@ describe('DefaultCatalogProcessingOrchestrator', () => {
|
||||
|
||||
const integrations = ScmIntegrations.fromConfig(new ConfigReader({}));
|
||||
const processor: jest.Mocked<CatalogProcessor> = {
|
||||
getProcessorName: jest.fn(),
|
||||
validateEntityKind: jest.fn(async () => true),
|
||||
readLocation: jest.fn(async (_l, _o, emit) => {
|
||||
emit(results.entity({ type: 't', target: 't' }, entity));
|
||||
|
||||
@@ -21,7 +21,11 @@ class MyProcessor implements CatalogProcessor {
|
||||
getProcessorName = () => 'my-processor';
|
||||
}
|
||||
|
||||
class OtherProcessor implements CatalogProcessor {}
|
||||
class OtherProcessor implements CatalogProcessor {
|
||||
getProcessorName(): string {
|
||||
return 'OtherProcessor';
|
||||
}
|
||||
}
|
||||
|
||||
describe('ProcessorCacheManager', () => {
|
||||
const myProcessor = new MyProcessor();
|
||||
|
||||
@@ -104,7 +104,7 @@ export class ProcessorCacheManager {
|
||||
key?: string,
|
||||
): CatalogProcessorCache {
|
||||
// constructor name will be deprecated in the future when we make `getProcessorName` required in the implementation
|
||||
const name = processor.getProcessorName?.() ?? processor.constructor.name;
|
||||
const name = processor.getProcessorName();
|
||||
const cache = this.caches.get(name);
|
||||
if (cache) {
|
||||
return key ? cache.withKey(key) : cache;
|
||||
|
||||
@@ -431,6 +431,8 @@ export const runCommand: ({
|
||||
|
||||
// @public (undocumented)
|
||||
export class ScaffolderEntitiesProcessor implements CatalogProcessor {
|
||||
// (undocumented)
|
||||
getProcessorName(): string;
|
||||
// (undocumented)
|
||||
postProcessEntity(
|
||||
entity: Entity,
|
||||
|
||||
@@ -34,6 +34,10 @@ import {
|
||||
|
||||
/** @public */
|
||||
export class ScaffolderEntitiesProcessor implements CatalogProcessor {
|
||||
getProcessorName(): string {
|
||||
return 'ScaffolderEntitiesProcessor';
|
||||
}
|
||||
|
||||
private readonly validators = [templateEntityV1beta3Validator];
|
||||
|
||||
async validateEntityKind(entity: Entity): Promise<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user