From 77980e3f80b0e0001ddf78331ba9abe509000e81 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Wed, 10 Sep 2025 09:37:31 +0200 Subject: [PATCH] catalog-backend: rename type to spec.type Signed-off-by: Vincenzo Scamporlino --- .changeset/rotten-hairs-attack.md | 4 ++-- plugins/catalog-backend/config.d.ts | 2 +- plugins/catalog-backend/src/ingestion/CatalogRules.test.ts | 2 +- plugins/catalog-backend/src/ingestion/CatalogRules.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.changeset/rotten-hairs-attack.md b/.changeset/rotten-hairs-attack.md index 1b89ad46e7..7754441f78 100644 --- a/.changeset/rotten-hairs-attack.md +++ b/.changeset/rotten-hairs-attack.md @@ -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 diff --git a/plugins/catalog-backend/config.d.ts b/plugins/catalog-backend/config.d.ts index d346f01e37..4b349405cc 100644 --- a/plugins/catalog-backend/config.d.ts +++ b/plugins/catalog-backend/config.d.ts @@ -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; + allow: Array; /** * Limit this rule to a specific location * diff --git a/plugins/catalog-backend/src/ingestion/CatalogRules.test.ts b/plugins/catalog-backend/src/ingestion/CatalogRules.test.ts index 67d1e86248..a28ceb0d48 100644 --- a/plugins/catalog-backend/src/ingestion/CatalogRules.test.ts +++ b/plugins/catalog-backend/src/ingestion/CatalogRules.test.ts @@ -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/**' }], }, ], diff --git a/plugins/catalog-backend/src/ingestion/CatalogRules.ts b/plugins/catalog-backend/src/ingestion/CatalogRules.ts index ddb6398bf6..b348f5b752 100644 --- a/plugins/catalog-backend/src/ingestion/CatalogRules.ts +++ b/plugins/catalog-backend/src/ingestion/CatalogRules.ts @@ -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; }