Skip to content

Commit

Permalink
feat(kustomize): support OCI helm charts (#27163)
Browse files Browse the repository at this point in the history
Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
chancez and viceice committed Mar 13, 2024
1 parent b92afa4 commit 91bf759
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
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

0 comments on commit 91bf759

Please sign in to comment.