From 54e718e671e4e6e358ac982710716b89ad345759 Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov <5330267+kuzaxak@users.noreply.github.com> Date: Sun, 22 Dec 2024 12:14:53 +0200 Subject: feat(manager/helmfile): allow forward slashes in OCI chart names (#33162) --- lib/modules/manager/helmfile/extract.spec.ts | 26 ++++++++++++++++++++++++++ lib/modules/manager/helmfile/extract.ts | 16 +++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/modules/manager/helmfile/extract.spec.ts b/lib/modules/manager/helmfile/extract.spec.ts index 9ce660515e7..9c36f13f5f9 100644 --- a/lib/modules/manager/helmfile/extract.spec.ts +++ b/lib/modules/manager/helmfile/extract.spec.ts @@ -363,6 +363,32 @@ describe('modules/manager/helmfile/extract', () => { }); }); + it('allows OCI chart names containing forward slashes', async () => { + const content = ` + repositories: + - name: oci-repo + url: ghcr.io/example/oci-repo + oci: true + releases: + - name: nested-example + version: 1.2.3 + chart: oci-repo/nested/path/chart + `; + const fileName = 'helmfile.yaml'; + const result = await extractPackageFile(content, fileName, {}); + expect(result).toMatchObject({ + datasource: 'helm', + deps: [ + { + currentValue: '1.2.3', + depName: 'nested/path/chart', + datasource: 'docker', + packageName: 'ghcr.io/example/oci-repo/nested/path/chart', + }, + ], + }); + }); + it('parses a chart with an oci repository with ---', async () => { const content = codeBlock` repositories: diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index eaff3133dee..5b11c9b0edc 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -18,8 +18,13 @@ import { localChartHasKustomizationsYaml, } from './utils'; -const isValidChartName = (name: string | undefined): boolean => - !!name && !regEx(/[!@#$%^&*(),.?":{}/|<>A-Z]/).test(name); +function isValidChartName(name: string | undefined, oci: boolean): boolean { + if (oci) { + return !!name && !regEx(/[!@#$%^&*(),.?":{}|<>A-Z]/).test(name); + } else { + return !!name && !regEx(/[!@#$%^&*(),.?":{}/|<>A-Z]/).test(name); + } +} function isLocalPath(possiblePath: string): boolean { return ['./', '../', '/'].some((localPrefix) => @@ -118,7 +123,12 @@ export async function extractPackageFile( // By definition on helm the chart name should be lowercase letter + number + - // However helmfile support templating of that field - if (!isValidChartName(res.depName)) { + if ( + !isValidChartName( + res.depName, + isOCIRegistry(dep.chart) || (registryData[repoName]?.oci ?? false), + ) + ) { res.skipReason = 'unsupported-chart-type'; } -- cgit v1.2.3