Skip to content

Commit

Permalink
Use allowDuplicateKeys: true for yaml parsing throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
nktpro committed Mar 7, 2025
1 parent 9ccdab5 commit 35eaac8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/actions/typeify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ async function readChartValues(

const parsed = (() => {
try {
return parseYaml(raw);
return parseYaml(raw, { allowDuplicateKeys: true });
} catch (e) {
logger.warn?.(
`Failed parsing ${valuesPath}, going to ignore it`,
Expand Down
2 changes: 2 additions & 0 deletions src/actions/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async function getCurrentChartMetadata(
if (await fsExists(chartPath)) {
const currentChartMetaRaw = parseYaml(
await Deno.readTextFile(joinPath(chartPath, "Chart.yaml")),
{ allowDuplicateKeys: true },
);
const currentChartMetaResult = validate(
ChartMetadataSchema,
Expand Down Expand Up @@ -329,6 +330,7 @@ async function updateHelmRepoChart({

const remoteRepoIndexRaw = parseYaml(
await fetchRemoteRepoIndexYaml(remoteRepoUrl),
{ allowDuplicateKeys: true },
);
const remoteRepoIndexResult = validate(
ChartRepoIndexSchema,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/iac_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function decryptAndValidateSecrets<T>(
}
})();

const decrypted = parseYaml(raw);
const decrypted = parseYaml(raw, { allowDuplicateKeys: true });

return validate(schema, decrypted);
}
Expand Down Expand Up @@ -92,7 +92,7 @@ export async function readChartMeta(chartPath: string): Promise<ChartMetadata> {
);

const chartMetaResult = validateChartMeta(
parseYaml(await Deno.readTextFile(chartMetaPath)),
parseYaml(await Deno.readTextFile(chartMetaPath), { allowDuplicateKeys: true }),
);

if (!chartMetaResult.isSuccess) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/yaml_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export function stringifyYamlRelaxed(value: unknown): string {
}

export function parseMultiDocumentsYaml(rawYaml: string): unknown[] {
return parseAll(rawYaml) as unknown[];
return parseAll(rawYaml, { allowDuplicateKeys: true }) as unknown[];
}

0 comments on commit 35eaac8

Please sign in to comment.