From 6040cd78a9f6399ad9f749805afb254f4f23d0a8 Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov Date: Tue, 17 Dec 2024 11:12:36 +0200 Subject: [PATCH 1/7] feat(manager/helmfile): allow forward slashes in OCI chart names Issue was described in [discussion][1]. The helmfile manager now properly handles OCI chart names that contain forward slashes. Previously, the validation would reject chart names with slashes even for OCI repositories. This change modifies the isValidChartName function to use different validation rules for OCI vs non-OCI charts. Added test coverage to verify the new behavior works correctly. [1]: https://github.com/renovatebot/renovate/discussions/26207 --- lib/modules/manager/helmfile/extract.spec.ts | 30 ++++++++++++++++++++ lib/modules/manager/helmfile/extract.ts | 11 +++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/modules/manager/helmfile/extract.spec.ts b/lib/modules/manager/helmfile/extract.spec.ts index 9ce660515e782f..a597ad72a13950 100644 --- a/lib/modules/manager/helmfile/extract.spec.ts +++ b/lib/modules/manager/helmfile/extract.spec.ts @@ -363,6 +363,36 @@ 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://ghcr.io/example/nested/path/chart + `; + const fileName = 'helmfile.yaml'; + const result = await extractPackageFile(content, fileName, { + registryAliases: { + stable: 'https://charts.helm.sh/stable', + }, + }); + expect(result).toMatchObject({ + datasource: 'helm', + deps: [ + { + currentValue: '1.2.3', + depName: 'path/chart', + datasource: 'docker', + packageName: 'ghcr.io/example/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 eaff3133deee3b..c098b493a0bd45 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); +const 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,7 @@ 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)) { res.skipReason = 'unsupported-chart-type'; } From 32ca4c4f57197f11a3fc9c9504ec6ecfad591a2f Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov Date: Tue, 17 Dec 2024 18:52:00 +0200 Subject: [PATCH 2/7] fixup! feat(manager/helmfile): allow forward slashes in OCI chart names --- lib/modules/manager/helmfile/extract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index c098b493a0bd45..0ad03185e55fcb 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -18,7 +18,7 @@ import { localChartHasKustomizationsYaml, } from './utils'; -const isValidChartName = (name: string | undefined, oci: boolean): boolean { +const isValidChartName = (name: string | undefined, oci: boolean): boolean => { if (oci) { return !!name && !regEx(/[!@#$%^&*(),.?":{}|<>A-Z]/).test(name); } else { From 32824dd55476e9ee6183e4c1f9866b8fe8aae219 Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov Date: Tue, 17 Dec 2024 18:56:15 +0200 Subject: [PATCH 3/7] fixup! feat(manager/helmfile): allow forward slashes in OCI chart names --- lib/modules/manager/helmfile/extract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index 0ad03185e55fcb..75c005b6cf62c3 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -123,7 +123,7 @@ 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, isOCIRegistry(dep.chart) || registryData[repoName]?.oci)) { + if (!isValidChartName(res.depName, isOCIRegistry(dep.chart) || (registryData[repoName]?.oci ?? false))) { res.skipReason = 'unsupported-chart-type'; } From 9193a858ccd9ce51f61f8de4fad0868bd4509bff Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov Date: Tue, 17 Dec 2024 19:09:07 +0200 Subject: [PATCH 4/7] fixup! feat(manager/helmfile): allow forward slashes in OCI chart names --- lib/modules/manager/helmfile/extract.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index 75c005b6cf62c3..fc259c541249a4 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -24,7 +24,7 @@ const isValidChartName = (name: string | undefined, oci: boolean): boolean => { } else { return !!name && !regEx(/[!@#$%^&*(),.?":{}/|<>A-Z]/).test(name); } -} +}; function isLocalPath(possiblePath: string): boolean { return ['./', '../', '/'].some((localPrefix) => @@ -123,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, isOCIRegistry(dep.chart) || (registryData[repoName]?.oci ?? false))) { + if ( + !isValidChartName( + res.depName, + isOCIRegistry(dep.chart) || (registryData[repoName]?.oci ?? false), + ) + ) { res.skipReason = 'unsupported-chart-type'; } From db1c0017b2c233e09733c45c76a2220f2f07d22c Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov Date: Tue, 17 Dec 2024 19:36:34 +0200 Subject: [PATCH 5/7] fixup! feat(manager/helmfile): allow forward slashes in OCI chart names --- lib/modules/manager/helmfile/extract.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/modules/manager/helmfile/extract.spec.ts b/lib/modules/manager/helmfile/extract.spec.ts index a597ad72a13950..8ccb94562f8b4f 100644 --- a/lib/modules/manager/helmfile/extract.spec.ts +++ b/lib/modules/manager/helmfile/extract.spec.ts @@ -372,7 +372,7 @@ describe('modules/manager/helmfile/extract', () => { releases: - name: nested-example version: 1.2.3 - chart: oci://ghcr.io/example/nested/path/chart + chart: oci-repo/nested/path/chart `; const fileName = 'helmfile.yaml'; const result = await extractPackageFile(content, fileName, { @@ -385,9 +385,9 @@ describe('modules/manager/helmfile/extract', () => { deps: [ { currentValue: '1.2.3', - depName: 'path/chart', + depName: 'nested/path/chart', datasource: 'docker', - packageName: 'ghcr.io/example/nested/path/chart', + packageName: 'ghcr.io/example/oci-repo/nested/path/chart', }, ], }); From 4f735092764b5677251d9597f531a107ff06ca2a Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov Date: Tue, 17 Dec 2024 23:52:45 +0200 Subject: [PATCH 6/7] fixup! feat(manager/helmfile): allow forward slashes in OCI chart names --- lib/modules/manager/helmfile/extract.spec.ts | 6 +----- lib/modules/manager/helmfile/extract.ts | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/modules/manager/helmfile/extract.spec.ts b/lib/modules/manager/helmfile/extract.spec.ts index 8ccb94562f8b4f..9c36f13f5f91d5 100644 --- a/lib/modules/manager/helmfile/extract.spec.ts +++ b/lib/modules/manager/helmfile/extract.spec.ts @@ -375,11 +375,7 @@ describe('modules/manager/helmfile/extract', () => { chart: oci-repo/nested/path/chart `; const fileName = 'helmfile.yaml'; - const result = await extractPackageFile(content, fileName, { - registryAliases: { - stable: 'https://charts.helm.sh/stable', - }, - }); + const result = await extractPackageFile(content, fileName, {}); expect(result).toMatchObject({ datasource: 'helm', deps: [ diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index fc259c541249a4..0f9e7c5f8a4cce 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -18,7 +18,7 @@ import { localChartHasKustomizationsYaml, } from './utils'; -const isValidChartName = (name: string | undefined, oci: boolean): boolean => { +function isValidChartName(name: string | undefined, oci: boolean): boolean { if (oci) { return !!name && !regEx(/[!@#$%^&*(),.?":{}|<>A-Z]/).test(name); } else { From 419ce6828ad61d33609f11e2a2a75c60039530f8 Mon Sep 17 00:00:00 2001 From: Vladimir Kuznichenkov Date: Wed, 18 Dec 2024 09:51:50 +0200 Subject: [PATCH 7/7] fixup! feat(manager/helmfile): allow forward slashes in OCI chart names --- lib/modules/manager/helmfile/extract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index 0f9e7c5f8a4cce..5b11c9b0edc5a8 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -24,7 +24,7 @@ function isValidChartName(name: string | undefined, oci: boolean): boolean { } else { return !!name && !regEx(/[!@#$%^&*(),.?":{}/|<>A-Z]/).test(name); } -}; +} function isLocalPath(possiblePath: string): boolean { return ['./', '../', '/'].some((localPrefix) =>