feat(catalog): allow setting EntityDataParser using CatalogProcessingExtensionPoint
Signed-off-by: secustor <sebastian@poxhofer.at>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': minor
|
||||
'@backstage/plugin-catalog-node': minor
|
||||
---
|
||||
|
||||
Allow setting EntityDataParser using CatalogProcessingExtensionPoint
|
||||
@@ -28,11 +28,13 @@ import {
|
||||
} from '@backstage/plugin-catalog-node/alpha';
|
||||
import {
|
||||
CatalogProcessor,
|
||||
CatalogProcessorParser,
|
||||
EntityProvider,
|
||||
ScmLocationAnalyzer,
|
||||
} from '@backstage/plugin-catalog-node';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import { PlaceholderResolver } from '../modules';
|
||||
import { defaultEntityDataParser } from '../modules/util/parse';
|
||||
|
||||
class CatalogProcessingExtensionPointImpl
|
||||
implements CatalogProcessingExtensionPoint
|
||||
@@ -40,6 +42,7 @@ class CatalogProcessingExtensionPointImpl
|
||||
#processors = new Array<CatalogProcessor>();
|
||||
#entityProviders = new Array<EntityProvider>();
|
||||
#placeholderResolvers: Record<string, PlaceholderResolver> = {};
|
||||
entityDataParser: CatalogProcessorParser = defaultEntityDataParser;
|
||||
|
||||
addProcessor(
|
||||
...processors: Array<CatalogProcessor | Array<CatalogProcessor>>
|
||||
@@ -61,6 +64,10 @@ class CatalogProcessingExtensionPointImpl
|
||||
this.#placeholderResolvers[key] = resolver;
|
||||
}
|
||||
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void {
|
||||
this.entityDataParser = parser;
|
||||
}
|
||||
|
||||
get processors() {
|
||||
return this.#processors;
|
||||
}
|
||||
@@ -164,6 +171,8 @@ export const catalogPlugin = createBackendPlugin({
|
||||
});
|
||||
builder.addProcessor(...processingExtensions.processors);
|
||||
builder.addEntityProvider(...processingExtensions.entityProviders);
|
||||
builder.setEntityDataParser(processingExtensions.entityDataParser);
|
||||
|
||||
Object.entries(processingExtensions.placeholderResolvers).forEach(
|
||||
([key, resolver]) => builder.setPlaceholderResolver(key, resolver),
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
```ts
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { CatalogProcessor } from '@backstage/plugin-catalog-node';
|
||||
import { CatalogProcessorParser } from '@backstage/plugin-catalog-node';
|
||||
import { EntitiesSearchFilter } from '@backstage/plugin-catalog-node';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-node';
|
||||
@@ -54,6 +55,8 @@ export interface CatalogProcessingExtensionPoint {
|
||||
addProcessor(
|
||||
...processors: Array<CatalogProcessor | Array<CatalogProcessor>>
|
||||
): void;
|
||||
// (undocumented)
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void;
|
||||
}
|
||||
|
||||
// @alpha (undocumented)
|
||||
|
||||
@@ -18,6 +18,7 @@ import { createExtensionPoint } from '@backstage/backend-plugin-api';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import {
|
||||
CatalogProcessor,
|
||||
CatalogProcessorParser,
|
||||
EntitiesSearchFilter,
|
||||
EntityProvider,
|
||||
PlaceholderResolver,
|
||||
@@ -37,6 +38,7 @@ export interface CatalogProcessingExtensionPoint {
|
||||
...providers: Array<EntityProvider | Array<EntityProvider>>
|
||||
): void;
|
||||
addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void;
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user