Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(manager/helmfile): allow forward slashes in OCI chart names #33162

Merged
merged 7 commits into from
Dec 22, 2024
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
Loading