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(kustomize): support OCI helm charts #27163

Merged
merged 11 commits into from Mar 13, 2024
Expand Up @@ -13,3 +13,7 @@ helmCharts:
releaseName: moria
version: 3.1.3
repo: https://itzg.github.io/minecraft-server-charts
- name: redis
releaseName: redis
version: 18.12.1
repo: oci://registry-1.docker.io/bitnamicharts
Expand Up @@ -174,6 +174,15 @@ exports[`modules/manager/kustomize/extract extractPackageFile() parses helmChart
"https://itzg.github.io/minecraft-server-charts",
],
},
{
"currentDigest": undefined,
"currentValue": "18.12.1",
"datasource": "docker",
"depName": "redis",
"depType": "HelmChart",
"packageName": "registry-1.docker.io/bitnamicharts/redis",
"pinDigests": false,
},
],
}
`;
Expand Down
25 changes: 25 additions & 0 deletions lib/modules/manager/kustomize/extract.spec.ts
Expand Up @@ -175,6 +175,22 @@ describe('modules/manager/kustomize/extract', () => {
});
expect(pkg).toEqual(sample);
});

it('should correctly extract an OCI chart', () => {
const sample = {
depName: 'redis',
packageName: 'registry-1.docker.io/bitnamicharts/redis',
currentValue: '18.12.1',
datasource: DockerDatasource.id,
pinDigests: false,
};
const pkg = extractHelmChart({
name: sample.depName,
version: sample.currentValue,
repo: 'oci://registry-1.docker.io/bitnamicharts',
});
expect(pkg).toEqual(sample);
});
});

describe('image extraction', () => {
Expand Down Expand Up @@ -501,8 +517,17 @@ describe('modules/manager/kustomize/extract', () => {
depType: 'HelmChart',
depName: 'minecraft',
currentValue: '3.1.3',
datasource: HelmDatasource.id,
registryUrls: ['https://itzg.github.io/minecraft-server-charts'],
},
{
depType: 'HelmChart',
depName: 'redis',
currentValue: '18.12.1',
datasource: DockerDatasource.id,
packageName: 'registry-1.docker.io/bitnamicharts/redis',
pinDigests: false,
},
],
});
});
Expand Down
20 changes: 19 additions & 1 deletion lib/modules/manager/kustomize/extract.ts
Expand Up @@ -7,6 +7,7 @@ import { GitTagsDatasource } from '../../datasource/git-tags';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { HelmDatasource } from '../../datasource/helm';
import { getDep } from '../dockerfile/extract';
import { isOCIRegistry } from '../helmv3/utils';
import type {
ExtractConfig,
PackageDependency,
Expand Down Expand Up @@ -140,11 +141,28 @@ export function extractImage(

export function extractHelmChart(
helmChart: HelmChart,
aliases?: Record<string, string> | undefined,
): PackageDependency | null {
if (!helmChart.name) {
return null;
}

if (isOCIRegistry(helmChart.repo)) {
const dep = getDep(
`${helmChart.repo.replace('oci://', '')}/${helmChart.name}:${helmChart.version}`,
false,
aliases,
);
return {
...dep,
depName: helmChart.name,
packageName: dep.depName,
// https://github.com/helm/helm/issues/10312
// https://github.com/helm/helm/issues/10678
pinDigests: false,
};
}

return {
depName: helmChart.name,
currentValue: helmChart.version,
Expand Down Expand Up @@ -238,7 +256,7 @@ export function extractPackageFile(

// grab the helm charts
for (const helmChart of coerceArray(pkg.helmCharts)) {
const dep = extractHelmChart(helmChart);
const dep = extractHelmChart(helmChart, config.registryAliases);
if (dep) {
deps.push({
...dep,
Expand Down
1 change: 1 addition & 0 deletions lib/modules/manager/kustomize/readme.md
Expand Up @@ -18,6 +18,7 @@ This manager uses three `depType`s to allow fine-grained control of which depend
- Component
- Kustomization
- HelmChart
- OCIChart

**Limitations**

Expand Down