feat(catalog): config to support disabling processors and providers
this adds support to disable individual catalog processors and providers via config. relates to #31007 Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
---
|
||||
|
||||
Add support to disable catalog providers and processors via configuration
|
||||
Vendored
+32
@@ -221,5 +221,37 @@ export interface Config {
|
||||
* housing catalog-info files.
|
||||
*/
|
||||
processingInterval?: HumanDuration | false;
|
||||
|
||||
/**
|
||||
* Catalog provide specific configuration.
|
||||
* Additional configuration for providers are specified in the catalog
|
||||
* modules.
|
||||
*/
|
||||
providers?: {
|
||||
/**
|
||||
* Name is the provider ID, e.g. "bitbucketServer"
|
||||
*/
|
||||
[name: string]: {
|
||||
/**
|
||||
* Whether the provider is enabled or not. Defaults to true.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Configuration for entity processors. Additional configuration for
|
||||
* processors are specified in the catalog modules.
|
||||
*/
|
||||
processors?: {
|
||||
/**
|
||||
* Name is the processor ID, e.g. "catalog-processor"
|
||||
*/
|
||||
[name: string]: {
|
||||
/**
|
||||
* Whether the processor is enabled or not. Defaults to true.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -568,9 +568,11 @@ export class CatalogBuilder {
|
||||
|
||||
const locationStore = new DefaultLocationStore(dbClient);
|
||||
const configLocationProvider = new ConfigLocationEntityProvider(config);
|
||||
const entityProviders = lodash.uniqBy(
|
||||
[...this.entityProviders, locationStore, configLocationProvider],
|
||||
provider => provider.getProviderName(),
|
||||
const entityProviders = this.filterProviders(
|
||||
lodash.uniqBy(
|
||||
[...this.entityProviders, locationStore, configLocationProvider],
|
||||
provider => provider.getProviderName(),
|
||||
),
|
||||
);
|
||||
|
||||
const processingEngine = new DefaultCatalogProcessingEngine({
|
||||
@@ -725,7 +727,30 @@ export class CatalogBuilder {
|
||||
|
||||
this.checkMissingExternalProcessors(processors);
|
||||
|
||||
return processors;
|
||||
return this.filterProcessors(processors);
|
||||
}
|
||||
|
||||
private filterProcessors(processors: CatalogProcessor[]) {
|
||||
const { config } = this.env;
|
||||
const processorsConfig = config.getOptionalConfig('catalog.processors');
|
||||
if (!processorsConfig) {
|
||||
return processors;
|
||||
}
|
||||
const keys = Object.keys(processorsConfig);
|
||||
for (const key of keys) {
|
||||
if (!processors.find(p => p.getProcessorName() === key)) {
|
||||
this.env.logger.warn(
|
||||
`Invalid catalog processor configuration catalog.processors.${key}: no such processor`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return processors.filter(p => {
|
||||
const processorConfig = processorsConfig.getOptionalConfig(
|
||||
p.getProcessorName(),
|
||||
);
|
||||
return processorConfig?.getOptionalBoolean('enabled') ?? true;
|
||||
});
|
||||
}
|
||||
|
||||
// TODO(Rugvip): These old processors are removed, for a while we'll be throwing
|
||||
@@ -838,6 +863,30 @@ export class CatalogBuilder {
|
||||
);
|
||||
}
|
||||
|
||||
private filterProviders(providers: EntityProvider[]) {
|
||||
const { config, logger } = this.env;
|
||||
const providersConfig = config.getOptionalConfig('catalog.providers');
|
||||
if (!providersConfig) {
|
||||
return providers;
|
||||
}
|
||||
|
||||
const keys = Object.keys(providersConfig);
|
||||
for (const key of keys) {
|
||||
if (!providers.find(p => p.getProviderName() === key)) {
|
||||
logger.warn(
|
||||
`Invalid catalog provider configuration catalog.providers.${key}: no such provider`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return providers.filter(p => {
|
||||
const providerConfig = providersConfig.getOptionalConfig(
|
||||
p.getProviderName(),
|
||||
);
|
||||
return providerConfig?.getOptionalBoolean('enabled') ?? true;
|
||||
});
|
||||
}
|
||||
|
||||
private static getDefaultProcessingInterval(
|
||||
config: Config,
|
||||
): ProcessingIntervalFunction {
|
||||
|
||||
Reference in New Issue
Block a user