catalog-backend: rename type to spec.type
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
'@backstage/plugin-catalog-backend': minor
|
||||
---
|
||||
|
||||
Add support for specifying an entity `type` in `catalog.rules.allow` rules within the catalog configuration.
|
||||
Add support for specifying an entity `spec.type` in `catalog.rules.allow` rules within the catalog configuration.
|
||||
|
||||
For example, this enables allowing all `Template` entities with the type `website`:
|
||||
|
||||
@@ -18,7 +18,7 @@ For example, this enables allowing all `Template` entities with the type `websit
|
||||
- Location
|
||||
+ - allow:
|
||||
+ - kind: Template
|
||||
+ type: website
|
||||
+ spec.type: website
|
||||
locations:
|
||||
- type: url
|
||||
pattern: https://github.com/org/*\/blob/master/*.yaml
|
||||
|
||||
Vendored
+1
-1
@@ -42,7 +42,7 @@ export interface Config {
|
||||
* You can also specify the type of the entity by using an object with `kind` and optional `type` properties.
|
||||
* E.g. [{ kind: "Component", type: "service" }]
|
||||
*/
|
||||
allow: Array<string | { kind: string; type?: string }>;
|
||||
allow: Array<string | { kind: string; 'spec.type'?: string }>;
|
||||
/**
|
||||
* Limit this rule to a specific location
|
||||
*
|
||||
|
||||
@@ -283,7 +283,7 @@ describe('DefaultCatalogRulesEnforcer', () => {
|
||||
catalog: {
|
||||
rules: [
|
||||
{
|
||||
allow: [{ kind: 'Component', type: 'service' }],
|
||||
allow: [{ kind: 'Component', 'spec.type': 'service' }],
|
||||
locations: [{ type: 'url', pattern: 'https://github.com/b/**' }],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -36,7 +36,7 @@ export type CatalogRule = {
|
||||
|
||||
type CatalogRuleAllow = {
|
||||
kind: string;
|
||||
type?: string;
|
||||
'spec.type'?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -222,7 +222,7 @@ export class DefaultCatalogRulesEnforcer implements CatalogRulesEnforcer {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (matcher.type && matcher.type !== entity.spec?.type) {
|
||||
if (matcher['spec.type'] && matcher['spec.type'] !== entity.spec?.type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user