Skip to content

Commit

Permalink
feat(manager/helmfile): allow forward slashes in OCI chart names (#33162
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kuzaxak authored Dec 22, 2024
1 parent f1a9b24 commit 54e718e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
26 changes: 26 additions & 0 deletions lib/modules/manager/helmfile/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 13 additions & 3 deletions lib/modules/manager/helmfile/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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';
}

Expand Down

0 comments on commit 54e718e

Please sign in to comment.