diff --git a/plugins/catalog/src/alpha/filter/matrchers/createHasMatcher.ts b/plugins/catalog/src/alpha/filter/matrchers/createHasMatcher.ts index f57316a65e..35a3f7baf7 100644 --- a/plugins/catalog/src/alpha/filter/matrchers/createHasMatcher.ts +++ b/plugins/catalog/src/alpha/filter/matrchers/createHasMatcher.ts @@ -17,6 +17,18 @@ import { InputError } from '@backstage/errors'; import { EntityMatcherFn } from './types'; +const allowedMatchers: Record = { + labels: entity => { + return Object.keys(entity.metadata.labels ?? {}).length > 0; + }, + annotations: entity => { + return Object.keys(entity.metadata.annotations ?? {}).length > 0; + }, + links: entity => { + return (entity.metadata.links ?? []).length > 0; + }, +}; + /** * Matches on the non-empty presence of different parts of the entity */ @@ -24,18 +36,6 @@ export function createHasMatcher( parameters: string[], onParseError: (error: Error) => void, ): EntityMatcherFn { - const allowedMatchers: Record = { - labels: entity => { - return Object.keys(entity.metadata.labels ?? {}).length > 0; - }, - annotations: entity => { - return Object.keys(entity.metadata.annotations ?? {}).length > 0; - }, - links: entity => { - return (entity.metadata.links ?? []).length > 0; - }, - }; - const matchers = parameters.flatMap(parameter => { const matcher = allowedMatchers[parameter.toLocaleLowerCase('en-US')]; if (!matcher) { diff --git a/plugins/catalog/src/alpha/filter/matrchers/createIsMatcher.ts b/plugins/catalog/src/alpha/filter/matrchers/createIsMatcher.ts index 30bfe4eb15..49a54349d1 100644 --- a/plugins/catalog/src/alpha/filter/matrchers/createIsMatcher.ts +++ b/plugins/catalog/src/alpha/filter/matrchers/createIsMatcher.ts @@ -17,6 +17,11 @@ import { InputError } from '@backstage/errors'; import { EntityMatcherFn } from './types'; +const allowedMatchers: Record = { + orphan: entity => + Boolean(entity.metadata.annotations?.['backstage.io/orphan']), +}; + /** * Matches on different semantic properties of the entity */ @@ -24,11 +29,6 @@ export function createIsMatcher( parameters: string[], onParseError: (error: Error) => void, ): EntityMatcherFn { - const allowedMatchers: Record = { - orphan: entity => - Boolean(entity.metadata.annotations?.['backstage.io/orphan']), - }; - const matchers = parameters.flatMap(parameter => { const matcher = allowedMatchers[parameter.toLocaleLowerCase('en-US')]; if (!matcher) {