Enable addition of permission rules for Catalog plugin through CatalogProcessingExtensionPoint
Signed-off-by: lshwayne96 <lshwayne96@gmail.com>
This commit is contained in:
committed by
Fredrik Adelöw
parent
cedcebf1a4
commit
7804597717
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': minor
|
||||
'@backstage/plugin-catalog-node': minor
|
||||
---
|
||||
|
||||
Permission rules can now be added for the Catalog plugin through the `CatalogProcessingExtensionPoint` interface.
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
createBackendPlugin,
|
||||
coreServices,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { CatalogBuilder } from './CatalogBuilder';
|
||||
import { CatalogBuilder, CatalogPermissionRuleInput } from './CatalogBuilder';
|
||||
import {
|
||||
CatalogAnalysisExtensionPoint,
|
||||
catalogAnalysisExtensionPoint,
|
||||
@@ -38,6 +38,7 @@ class CatalogProcessingExtensionPointImpl
|
||||
#processors = new Array<CatalogProcessor>();
|
||||
#entityProviders = new Array<EntityProvider>();
|
||||
#placeholderResolvers: Record<string, PlaceholderResolver> = {};
|
||||
#permissionRules = new Array<CatalogPermissionRuleInput>();
|
||||
|
||||
addProcessor(
|
||||
...processors: Array<CatalogProcessor | Array<CatalogProcessor>>
|
||||
@@ -59,6 +60,14 @@ class CatalogProcessingExtensionPointImpl
|
||||
this.#placeholderResolvers[key] = resolver;
|
||||
}
|
||||
|
||||
addPermissionRules(
|
||||
...rules: Array<
|
||||
CatalogPermissionRuleInput | Array<CatalogPermissionRuleInput>
|
||||
>
|
||||
): void {
|
||||
this.#permissionRules.push(...rules.flat());
|
||||
}
|
||||
|
||||
get processors() {
|
||||
return this.#processors;
|
||||
}
|
||||
@@ -70,6 +79,10 @@ class CatalogProcessingExtensionPointImpl
|
||||
get placeholderResolvers() {
|
||||
return this.#placeholderResolvers;
|
||||
}
|
||||
|
||||
get permissionRules() {
|
||||
return this.#permissionRules;
|
||||
}
|
||||
}
|
||||
|
||||
class CatalogAnalysisExtensionPointImpl
|
||||
@@ -142,6 +155,7 @@ export const catalogPlugin = createBackendPlugin({
|
||||
([key, resolver]) => builder.setPlaceholderResolver(key, resolver),
|
||||
);
|
||||
builder.addLocationAnalyzers(...analysisExtensions.locationAnalyzers);
|
||||
builder.addPermissionRules(...processingExtensions.permissionRules);
|
||||
|
||||
const { processingEngine, router } = await builder.build();
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
"@backstage/catalog-client": "workspace:^",
|
||||
"@backstage/catalog-model": "workspace:^",
|
||||
"@backstage/errors": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend": "workspace:^",
|
||||
"@backstage/plugin-catalog-common": "workspace:^",
|
||||
"@backstage/types": "workspace:^"
|
||||
},
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createExtensionPoint } from '@backstage/backend-plugin-api';
|
||||
import { CatalogPermissionRuleInput } from '@backstage/plugin-catalog-backend';
|
||||
import {
|
||||
EntityProvider,
|
||||
CatalogProcessor,
|
||||
@@ -32,6 +33,11 @@ export interface CatalogProcessingExtensionPoint {
|
||||
...providers: Array<EntityProvider | Array<EntityProvider>>
|
||||
): void;
|
||||
addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void;
|
||||
addPermissionRules(
|
||||
...rules: Array<
|
||||
CatalogPermissionRuleInput | Array<CatalogPermissionRuleInput>
|
||||
>
|
||||
): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5939,6 +5939,7 @@ __metadata:
|
||||
"@backstage/catalog-model": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/errors": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend": "workspace:^"
|
||||
"@backstage/plugin-catalog-common": "workspace:^"
|
||||
"@backstage/types": "workspace:^"
|
||||
languageName: unknown
|
||||
|
||||
Reference in New Issue
Block a user