Skip to content

Commit

Permalink
feat: Add getDefaultProcessors to CatalogBuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce Larson <bryce.larson@originenergy.com.au>
  • Loading branch information
Bryce Larson committed Nov 4, 2021
1 parent 7d64e37 commit b90fc74
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-panthers-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---

adds getDefaultProcessor method to CatalogBuilder
38 changes: 27 additions & 11 deletions plugins/catalog-backend/src/service/NextCatalogBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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 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.
*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b90fc74

Please sign in to comment.