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/helmv3): support helm chart dependencies in OCI images #11584

Merged
merged 2 commits into from Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/manager/helmv3/__snapshots__/artifacts.spec.ts.snap
Expand Up @@ -19,6 +19,7 @@ Array [
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": Object {
"HELM_EXPERIMENTAL_OCI": "1",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
Expand Down Expand Up @@ -53,6 +54,7 @@ Array [
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": Object {
"HELM_EXPERIMENTAL_OCI": "1",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
Expand Down Expand Up @@ -87,6 +89,7 @@ Array [
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": Object {
"HELM_EXPERIMENTAL_OCI": "1",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
Expand Down Expand Up @@ -128,11 +131,12 @@ Array [
},
},
Object {
"cmd": "docker run --rm --name=renovate_helm --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -w \\"/tmp/github/some/repo\\" renovate/helm bash -l -c \\"helm dependency update ''\\"",
"cmd": "docker run --rm --name=renovate_helm --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -e HELM_EXPERIMENTAL_OCI -w \\"/tmp/github/some/repo\\" renovate/helm bash -l -c \\"helm dependency update ''\\"",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": Object {
"HELM_EXPERIMENTAL_OCI": "1",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
Expand Down
23 changes: 23 additions & 0 deletions lib/manager/helmv3/__snapshots__/extract.spec.ts.snap
@@ -1,5 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`manager/helmv3/extract extractPackageFile() extract correctly oci references 1`] = `
Object {
"datasource": "helm",
"deps": Array [
Object {
"currentValue": "0.1.0",
"datasource": "docker",
"depName": "library",
"lookupName": "ghcr.io/ankitabhopatkar13/library",
"registryUrls": Array [],
},
Object {
"currentValue": "0.8.1",
"depName": "postgresql",
"registryUrls": Array [
"https://charts.helm.sh/stable",
],
},
],
"packageFileVersion": "0.1.0",
}
`;

exports[`manager/helmv3/extract extractPackageFile() parses simple Chart.yaml correctly 1`] = `
Object {
"datasource": "helm",
Expand Down
3 changes: 3 additions & 0 deletions lib/manager/helmv3/artifacts.ts
Expand Up @@ -17,6 +17,9 @@ async function helmUpdate(manifestPath: string): Promise<void> {
docker: {
image: 'helm',
},
extraEnv: {
HELM_EXPERIMENTAL_OCI: '1',
},
};
await exec(cmd, execOptions);
}
Expand Down
39 changes: 39 additions & 0 deletions lib/manager/helmv3/extract.spec.ts
@@ -1,4 +1,5 @@
import { fs } from '../../../test/util';
import * as datasourceDocker from '../../datasource/docker';
import { extractPackageFile } from './extract';

jest.mock('../../util/fs');
Expand Down Expand Up @@ -66,6 +67,44 @@ describe('manager/helmv3/extract', () => {
],
});
});

it('extract correctly oci references', async () => {
const content = `
apiVersion: v2
name: app2
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
dependencies:
- name: library
version: 0.1.0
repository: oci://ghcr.io/ankitabhopatkar13/library
import-values:
- defaults
- name: postgresql
version: 0.8.1
repository: https://charts.helm.sh/stable
condition: postgresql.enabled
`;
const fileName = 'Chart.yaml';
const result = await extractPackageFile(content, fileName, {
aliases: {
stable: 'https://charts.helm.sh/stable',
},
});
expect(result).toMatchSnapshot({
deps: [
{
depName: 'library',
datasource: datasourceDocker.id,
currentValue: '0.1.0',
},
{ depName: 'postgresql', currentValue: '0.8.1' },
],
});
});

it('resolves aliased registry urls', async () => {
const content = `
apiVersion: v2
Expand Down
13 changes: 11 additions & 2 deletions lib/manager/helmv3/extract.ts
@@ -1,5 +1,6 @@
import is from '@sindresorhus/is';
import { load } from 'js-yaml';
import * as datasourceDocker from '../../datasource/docker';
import { HelmDatasource } from '../../datasource/helm';
import { logger } from '../../logger';
import { SkipReason } from '../../types';
Expand Down Expand Up @@ -75,8 +76,16 @@ export async function extractPackageFile(
} else {
try {
const url = new URL(dep.repository);
if (url.protocol === 'file:') {
res.skipReason = SkipReason.LocalDependency;
switch (url.protocol) {
case 'oci:':
res.datasource = datasourceDocker.id;
res.lookupName = dep.repository.replace('oci://', '');
res.registryUrls = [];
break;
case 'file:':
res.skipReason = SkipReason.LocalDependency;
break;
default:
}
} catch (err) {
logger.debug({ err }, 'Error parsing url');
Expand Down