Merge pull request #17001 from thefrontside/BuiltinKindsEntityProcessor-override

Allow Replacement Of BuiltinKindsEntityProcessor
This commit is contained in:
Fredrik Adelöw
2023-03-23 09:03:23 +01:00
committed by GitHub
3 changed files with 20 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Allow replacement of the BuiltinKindsEntityProcessor which enables customization of schema validation and connections emitted.
@@ -170,6 +170,7 @@ its schema. There is a builtin processor that implements this for all known core
kinds and matches the data against their fixed validation schema. This processor
can be replaced when building the backend catalog using the `CatalogBuilder`,
with a processor of your own that validates the data differently.
This replacement processor must have a name that matches the builtin processor, `BuiltinKindsEntityProcessor`.
This type of extension is high risk, and may have high impact across the
ecosystem depending on the type of change that is made. It is therefore not
@@ -599,16 +599,28 @@ export class CatalogBuilder {
...this.placeholderResolvers,
};
// These are always there no matter what
// The placeholder is always there no matter what
const processors: CatalogProcessor[] = [
new PlaceholderProcessor({
resolvers: placeholderResolvers,
reader,
integrations,
}),
new BuiltinKindsEntityProcessor(),
];
const builtinKindsEntityProcessor = new BuiltinKindsEntityProcessor();
// If the user adds a processor named 'BuiltinKindsEntityProcessor',
// skip inclusion of the catalog-backend version.
if (
!this.processors.some(
processor =>
processor.getProcessorName() ===
builtinKindsEntityProcessor.getProcessorName(),
)
) {
processors.push(builtinKindsEntityProcessor);
}
// These are only added unless the user replaced them all
if (!this.processorsReplace) {
processors.push(...this.getDefaultProcessors());