Merge pull request #7885 from bryce-od/defaultProcessors

feat: Add getDefaultProcessors to CatalogBuilder
This commit is contained in:
Johan Haals
2021-11-15 11:48:56 +01:00
committed by GitHub
2 changed files with 33 additions and 12 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
adds getDefaultProcessor method to CatalogBuilder
@@ -265,7 +265,8 @@ export class NextCatalogBuilder {
* Sets what entity processors to use. These are responsible for reading,
* parsing, and processing entities before they are persisted in the catalog.
*
* This function replaces the default set of processors; use with care.
* This function replaces the default set of processors, consider using with
* {@link NextCatalogBuilder#getDefaultProcessors}; use with care.
*
* @param processors One or more processors
*/
@@ -275,6 +276,30 @@ export class NextCatalogBuilder {
return this;
}
/**
* Returns the default list of entity processors. These are responsible for reading,
* parsing, and processing entities before they are persisted in the catalog. Changing
* the order of processing can give more control to custom processors.
*
* Consider using with {@link NextCatalogBuilder#replaceProcessors}
*
*/
getDefaultProcessors(): CatalogProcessor[] {
const { config, logger, reader } = this.env;
const integrations = ScmIntegrations.fromConfig(config);
return [
new FileReaderProcessor(),
BitbucketDiscoveryProcessor.fromConfig(config, { logger }),
GithubDiscoveryProcessor.fromConfig(config, { logger }),
GithubOrgReaderProcessor.fromConfig(config, { logger }),
GitLabDiscoveryProcessor.fromConfig(config, { logger }),
new UrlReaderProcessor({ reader, logger }),
CodeOwnersProcessor.fromConfig(config, { logger, reader }),
new AnnotateLocationEntityProcessor({ integrations }),
];
}
/**
* Sets up the catalog to use a custom parser for entity data.
*
@@ -392,7 +417,7 @@ export class NextCatalogBuilder {
}
private buildProcessors(): CatalogProcessor[] {
const { config, logger, reader } = this.env;
const { config, reader } = this.env;
const integrations = ScmIntegrations.fromConfig(config);
this.checkDeprecatedReaderProcessors();
@@ -416,16 +441,7 @@ export class NextCatalogBuilder {
// These are only added unless the user replaced them all
if (!this.processorsReplace) {
processors.push(
new FileReaderProcessor(),
BitbucketDiscoveryProcessor.fromConfig(config, { logger }),
GithubDiscoveryProcessor.fromConfig(config, { logger }),
GithubOrgReaderProcessor.fromConfig(config, { logger }),
GitLabDiscoveryProcessor.fromConfig(config, { logger }),
new UrlReaderProcessor({ reader, logger }),
CodeOwnersProcessor.fromConfig(config, { logger, reader }),
new AnnotateLocationEntityProcessor({ integrations }),
);
processors.push(...this.getDefaultProcessors());
}
// Add the ones (if any) that the user added