Merge pull request #31034 from drodil/catalog_global_config

feat(catalog): config to support disabling processors and providers
This commit is contained in:
Fredrik Adelöw
2025-09-16 12:04:36 +02:00
committed by GitHub
3 changed files with 83 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Add support to disable catalog providers and processors via configuration
+32
View File
@@ -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,27 @@ 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;
}
return processors.filter(p => {
try {
const processorConfig = processorsConfig.getOptionalConfig(
p.getProcessorName(),
);
return processorConfig?.getOptionalBoolean('enabled') ?? true;
} catch (_) {
// In case the processor config is not an object, just include the processor
return true;
}
});
}
// TODO(Rugvip): These old processors are removed, for a while we'll be throwing
@@ -838,6 +860,26 @@ export class CatalogBuilder {
);
}
private filterProviders(providers: EntityProvider[]) {
const { config } = this.env;
const providersConfig = config.getOptionalConfig('catalog.providers');
if (!providersConfig) {
return providers;
}
return providers.filter(p => {
try {
const providerConfig = providersConfig.getOptionalConfig(
p.getProviderName(),
);
return providerConfig?.getOptionalBoolean('enabled') ?? true;
} catch (_) {
// In case the provider config is not an object, just include the provider
return true;
}
});
}
private static getDefaultProcessingInterval(
config: Config,
): ProcessingIntervalFunction {