feat(catalog): support onProcessingError handler at the catalog plugin
Add the missing support for the `onProcessingError` handler at the catalog plugin of the new backend system using the `CatalogProcessingExtensionPoint`. Related-to: #18301 Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
'@backstage/plugin-catalog-node': patch
|
||||
---
|
||||
|
||||
Add support for `onProcessingError` handler at the catalog plugin (new backend system).
|
||||
|
||||
You can use `setOnProcessingErrorHandler` at the `catalogProcessingExtensionPoint`
|
||||
as replacement for
|
||||
|
||||
```ts
|
||||
catalogBuilder.subscribe({
|
||||
onProcessingError: hander,
|
||||
});
|
||||
```
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
createBackendPlugin,
|
||||
coreServices,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { CatalogBuilder, CatalogPermissionRuleInput } from './CatalogBuilder';
|
||||
import {
|
||||
CatalogAnalysisExtensionPoint,
|
||||
@@ -40,6 +41,10 @@ class CatalogProcessingExtensionPointImpl
|
||||
#processors = new Array<CatalogProcessor>();
|
||||
#entityProviders = new Array<EntityProvider>();
|
||||
#placeholderResolvers: Record<string, PlaceholderResolver> = {};
|
||||
#onProcessingErrorHandler?: (event: {
|
||||
unprocessedEntity: Entity;
|
||||
errors: Error[];
|
||||
}) => Promise<void> | void;
|
||||
|
||||
addProcessor(
|
||||
...processors: Array<CatalogProcessor | Array<CatalogProcessor>>
|
||||
@@ -61,6 +66,15 @@ class CatalogProcessingExtensionPointImpl
|
||||
this.#placeholderResolvers[key] = resolver;
|
||||
}
|
||||
|
||||
setOnProcessingErrorHandler(
|
||||
handler: (event: {
|
||||
unprocessedEntity: Entity;
|
||||
errors: Error[];
|
||||
}) => Promise<void> | void,
|
||||
) {
|
||||
this.#onProcessingErrorHandler = handler;
|
||||
}
|
||||
|
||||
get processors() {
|
||||
return this.#processors;
|
||||
}
|
||||
@@ -72,6 +86,10 @@ class CatalogProcessingExtensionPointImpl
|
||||
get placeholderResolvers() {
|
||||
return this.#placeholderResolvers;
|
||||
}
|
||||
|
||||
get onProcessingErrorHandler() {
|
||||
return this.#onProcessingErrorHandler;
|
||||
}
|
||||
}
|
||||
|
||||
class CatalogAnalysisExtensionPointImpl
|
||||
@@ -162,6 +180,11 @@ export const catalogPlugin = createBackendPlugin({
|
||||
scheduler,
|
||||
logger: winstonLogger,
|
||||
});
|
||||
if (processingExtensions.onProcessingErrorHandler) {
|
||||
builder.subscribe({
|
||||
onProcessingError: processingExtensions.onProcessingErrorHandler,
|
||||
});
|
||||
}
|
||||
builder.addProcessor(...processingExtensions.processors);
|
||||
builder.addEntityProvider(...processingExtensions.entityProviders);
|
||||
Object.entries(processingExtensions.placeholderResolvers).forEach(
|
||||
|
||||
@@ -54,6 +54,13 @@ export interface CatalogProcessingExtensionPoint {
|
||||
addProcessor(
|
||||
...processors: Array<CatalogProcessor | Array<CatalogProcessor>>
|
||||
): void;
|
||||
// (undocumented)
|
||||
setOnProcessingErrorHandler(
|
||||
handler: (event: {
|
||||
unprocessedEntity: Entity;
|
||||
errors: Error[];
|
||||
}) => Promise<void> | void,
|
||||
): void;
|
||||
}
|
||||
|
||||
// @alpha (undocumented)
|
||||
|
||||
@@ -37,6 +37,12 @@ export interface CatalogProcessingExtensionPoint {
|
||||
...providers: Array<EntityProvider | Array<EntityProvider>>
|
||||
): void;
|
||||
addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void;
|
||||
setOnProcessingErrorHandler(
|
||||
handler: (event: {
|
||||
unprocessedEntity: Entity;
|
||||
errors: Error[];
|
||||
}) => Promise<void> | void,
|
||||
): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user