Merge pull request #29719 from backstage/frontend-app-api/support_filtering_extensions_config_by_features
Allow ignoring unknown extension config
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/frontend-app-api': patch
|
||||
---
|
||||
|
||||
Added the ability to ignore unknown extension config by passing `{ flags: { allowUnknownExtensionConfig: true } }` to `createSpecializedApp`.
|
||||
@@ -34,6 +34,9 @@ export function createSpecializedApp(options?: {
|
||||
extensionFactoryMiddleware?:
|
||||
| ExtensionFactoryMiddleware
|
||||
| ExtensionFactoryMiddleware[];
|
||||
flags?: {
|
||||
allowUnknownExtensionConfig?: boolean;
|
||||
};
|
||||
}): {
|
||||
apis: ApiHolder;
|
||||
tree: AppTree;
|
||||
|
||||
@@ -33,12 +33,14 @@ export function resolveAppNodeSpecs(options: {
|
||||
builtinExtensions?: Extension<any, any>[];
|
||||
parameters?: Array<ExtensionParameters>;
|
||||
forbidden?: Set<string>;
|
||||
allowUnknownExtensionConfig?: boolean;
|
||||
}): AppNodeSpec[] {
|
||||
const {
|
||||
builtinExtensions = [],
|
||||
parameters = [],
|
||||
forbidden = new Set(),
|
||||
features = [],
|
||||
allowUnknownExtensionConfig = false,
|
||||
} = options;
|
||||
|
||||
const plugins = features.filter(OpaqueFrontendPlugin.isType);
|
||||
@@ -202,7 +204,7 @@ export function resolveAppNodeSpecs(options: {
|
||||
existing.params.disabled = Boolean(overrideParam.disabled);
|
||||
}
|
||||
order.set(extensionId, existing);
|
||||
} else {
|
||||
} else if (!allowUnknownExtensionConfig) {
|
||||
throw new Error(`Extension ${extensionId} does not exist`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,6 +208,7 @@ export function createSpecializedApp(options?: {
|
||||
extensionFactoryMiddleware?:
|
||||
| ExtensionFactoryMiddleware
|
||||
| ExtensionFactoryMiddleware[];
|
||||
flags?: { allowUnknownExtensionConfig?: boolean };
|
||||
}): { apis: ApiHolder; tree: AppTree } {
|
||||
const config = options?.config ?? new ConfigReader({}, 'empty-config');
|
||||
const features = deduplicateFeatures(options?.features ?? []);
|
||||
@@ -221,6 +222,7 @@ export function createSpecializedApp(options?: {
|
||||
],
|
||||
parameters: readAppExtensionsConfig(config),
|
||||
forbidden: new Set(['root']),
|
||||
allowUnknownExtensionConfig: options?.flags?.allowUnknownExtensionConfig,
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user