diff --git a/lib/modules/manager/helmfile/__fixtures__/multidoc.yaml b/lib/modules/manager/helmfile/__fixtures__/multidoc.yaml index f194b9c30410a9..19f65754151bed 100644 --- a/lib/modules/manager/helmfile/__fixtures__/multidoc.yaml +++ b/lib/modules/manager/helmfile/__fixtures__/multidoc.yaml @@ -26,6 +26,8 @@ repositories: - name: prometheus-community url: https://prometheus-community.github.io/helm-charts +--- + templates: external-chart: &external-chart missingFileHandler: Debug diff --git a/lib/modules/manager/helmfile/extract.spec.ts b/lib/modules/manager/helmfile/extract.spec.ts index 279c57cd6e051a..abbddc6badf65b 100644 --- a/lib/modules/manager/helmfile/extract.spec.ts +++ b/lib/modules/manager/helmfile/extract.spec.ts @@ -1,3 +1,4 @@ +import { codeBlock } from 'common-tags'; import { Fixtures } from '../../../../test/fixtures'; import { fs } from '../../../../test/util'; import { GlobalConfig } from '../../../config/global'; @@ -14,6 +15,19 @@ describe('modules/manager/helmfile/extract', () => { GlobalConfig.set({ localDir }); }); + it('skip null YAML document', async () => { + const content = codeBlock` + ~ + `; + const fileName = 'helmfile.yaml'; + const result = await extractPackageFile(content, fileName, { + registryAliases: { + stable: 'https://charts.helm.sh/stable', + }, + }); + expect(result).toBeNull(); + }); + it('returns null if no releases', async () => { const content = ` repositories: diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index 379073c0c08f84..237a15157a09cf 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -31,7 +31,7 @@ export async function extractPackageFile( ): Promise { const deps: PackageDependency[] = []; let docs: Doc[]; - const registryAliases: Record = {}; + let registryAliases: Record = {}; // Record kustomization usage for all deps, since updating artifacts is run on the helmfile.yaml as a whole. let needKustomize = false; try { @@ -47,16 +47,26 @@ export async function extractPackageFile( return null; } for (const doc of docs) { - if (!(doc && is.array(doc.releases))) { + if (!doc) { continue; } + // Always check for repositories in the current document and override the existing ones if any (as YAML does) if (doc.repositories) { + registryAliases = {}; for (let i = 0; i < doc.repositories.length; i += 1) { registryAliases[doc.repositories[i].name] = doc.repositories[i].url; } + logger.debug( + { registryAliases, packageFile }, + `repositories discovered.`, + ); + } + + // Skip extraction if the document contains no releases + if (!is.array(doc.releases)) { + continue; } - logger.debug({ registryAliases }, 'repositories discovered.'); for (const dep of doc.releases) { let depName = dep.chart;