From 9d3ec06dfcdaa3ebe1c7ab6643600e0918dcaa8d Mon Sep 17 00:00:00 2001 From: Dharmik Date: Thu, 9 Oct 2025 21:36:52 -0300 Subject: [PATCH] support configurable Signed-off-by: Dharmik --- .changeset/easy-hands-grow.md | 6 ++++++ .../src/processors/PlaceholderProcessor.ts | 6 +++++- plugins/catalog-node/src/processing/parse.ts | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .changeset/easy-hands-grow.md diff --git a/.changeset/easy-hands-grow.md b/.changeset/easy-hands-grow.md new file mode 100644 index 0000000000..fc3cfd96e1 --- /dev/null +++ b/.changeset/easy-hands-grow.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog-backend': minor +'@backstage/plugin-catalog-node': minor +--- + +Make YAML merge (<<:) support configurable in the Backstage Catalog instead of always being enabled diff --git a/plugins/catalog-backend/src/processors/PlaceholderProcessor.ts b/plugins/catalog-backend/src/processors/PlaceholderProcessor.ts index acc833947e..b1b5493778 100644 --- a/plugins/catalog-backend/src/processors/PlaceholderProcessor.ts +++ b/plugins/catalog-backend/src/processors/PlaceholderProcessor.ts @@ -138,9 +138,13 @@ export async function yamlPlaceholderResolver( params.emit(processingResult.refresh(`url:${url}`)); + // YAML merge support False by default + const enableYamlMerge = false; + const parseOptions = { merge: enableYamlMerge }; + let documents: yaml.Document.Parsed[]; try { - documents = yaml.parseAllDocuments(content, { merge: true }).filter(d => d); + documents = yaml.parseAllDocuments(content, parseOptions).filter(d => d); } catch (e) { throw new Error( `Placeholder \$${params.key} failed to parse YAML data at ${params.value}, ${e}`, diff --git a/plugins/catalog-node/src/processing/parse.ts b/plugins/catalog-node/src/processing/parse.ts index 2ef276d06d..4647dc8afc 100644 --- a/plugins/catalog-node/src/processing/parse.ts +++ b/plugins/catalog-node/src/processing/parse.ts @@ -21,6 +21,10 @@ import { LocationSpec } from '@backstage/plugin-catalog-common'; import { CatalogProcessorResult } from '../api/processor'; import { processingResult } from '../api/processingResult'; +export interface ParseEntityYamlOptions { + enableYamlMerge?: boolean; +} + /** * A helper function that parses a YAML file, properly handling multiple * documents in a single file. @@ -40,12 +44,16 @@ import { processingResult } from '../api/processingResult'; export function* parseEntityYaml( data: string | Buffer, location: LocationSpec, + options?: ParseEntityYamlOptions, ): Iterable { + const parseOptions = { merge: options?.enableYamlMerge ?? false }; + let documents: yaml.Document.Parsed[]; try { documents = yaml .parseAllDocuments( typeof data === 'string' ? data : data.toString('utf8'), + parseOptions, ) .filter(d => d); } catch (e) {