Merge pull request #22265 from secustor/feat/allow-to-set-entity-data-parser
feat(catalog): allow setting EntityDataParser using CatalogProcessingExtensionPoint
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': minor
|
||||
'@backstage/plugin-catalog-node': minor
|
||||
---
|
||||
|
||||
Allow setting EntityDataParser using CatalogModelExtensionPoint
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
} from '@backstage/plugin-catalog-node/alpha';
|
||||
import {
|
||||
CatalogProcessor,
|
||||
CatalogProcessorParser,
|
||||
EntityProvider,
|
||||
PlaceholderResolver,
|
||||
ScmLocationAnalyzer,
|
||||
@@ -137,6 +138,21 @@ class CatalogModelExtensionPointImpl implements CatalogModelExtensionPoint {
|
||||
get fieldValidators() {
|
||||
return this.#fieldValidators;
|
||||
}
|
||||
|
||||
#entityDataParser?: CatalogProcessorParser;
|
||||
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void {
|
||||
if (this.#entityDataParser) {
|
||||
throw new Error(
|
||||
'Attempted to install second EntityDataParser. Only one can be set.',
|
||||
);
|
||||
}
|
||||
this.#entityDataParser = parser;
|
||||
}
|
||||
|
||||
get entityDataParser() {
|
||||
return this.#entityDataParser;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,6 +221,11 @@ export const catalogPlugin = createBackendPlugin({
|
||||
}
|
||||
builder.addProcessor(...processingExtensions.processors);
|
||||
builder.addEntityProvider(...processingExtensions.entityProviders);
|
||||
|
||||
if (modelExtensions.entityDataParser) {
|
||||
builder.setEntityDataParser(modelExtensions.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';
|
||||
@@ -27,6 +28,7 @@ export const catalogAnalysisExtensionPoint: ExtensionPoint<CatalogAnalysisExtens
|
||||
|
||||
// @alpha (undocumented)
|
||||
export interface CatalogModelExtensionPoint {
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void;
|
||||
setFieldValidators(validators: Partial<Validators>): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import { createExtensionPoint } from '@backstage/backend-plugin-api';
|
||||
import { Entity, Validators } from '@backstage/catalog-model';
|
||||
import {
|
||||
CatalogProcessor,
|
||||
CatalogProcessorParser,
|
||||
EntitiesSearchFilter,
|
||||
EntityProvider,
|
||||
PlaceholderResolver,
|
||||
@@ -55,6 +56,12 @@ export interface CatalogModelExtensionPoint {
|
||||
* @param validators - The (subset of) validators to set
|
||||
*/
|
||||
setFieldValidators(validators: Partial<Validators>): void;
|
||||
|
||||
/**
|
||||
* Sets the entity data parser which is used to read raw data from locations
|
||||
* @param parser - Parser which will used to extract entities from raw data
|
||||
*/
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user