support configurable

Signed-off-by: Dharmik <dharmik.gangani17@gmail.com>
This commit is contained in:
Dharmik
2025-10-09 21:36:52 -03:00
parent c773f80b4d
commit 9d3ec06dfc
3 changed files with 19 additions and 1 deletions
+6
View File
@@ -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
@@ -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}`,
@@ -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<CatalogProcessorResult> {
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) {