Skip to content

Commit

Permalink
feat: binarrySource=install for helm
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jan 21, 2022
1 parent 49f5ac0 commit bb311cd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
12 changes: 6 additions & 6 deletions lib/manager/helmv3/__snapshots__/artifacts.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,19 @@ Array [
exports[`manager/helmv3/artifacts returns updated Chart.lock with docker 2`] = `
Array [
Object {
"cmd": "docker pull renovate/helm",
"cmd": "docker pull renovate/sidecar",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker ps --filter name=renovate_helm -aq",
"cmd": "docker ps --filter name=renovate_sidecar -aq",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"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 ''\\"",
"cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -e HELM_EXPERIMENTAL_OCI -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool helm v3.7.2 && helm dependency update ''\\"",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand Down Expand Up @@ -244,19 +244,19 @@ Array [
exports[`manager/helmv3/artifacts sets repositories from aliases with docker 2`] = `
Array [
Object {
"cmd": "docker pull renovate/helm",
"cmd": "docker pull renovate/sidecar",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker ps --filter name=renovate_helm -aq",
"cmd": "docker ps --filter name=renovate_sidecar -aq",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"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 repo add stable the_stable_url && helm repo add repo1 the_repo1_url && helm dependency update ''\\"",
"cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -e HELM_EXPERIMENTAL_OCI -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool helm v3.7.2 && helm repo add stable the_stable_url && helm repo add repo1 the_repo1_url && helm dependency update ''\\"",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand Down
10 changes: 10 additions & 0 deletions lib/manager/helmv3/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import { envMock, mockExecAll } from '../../../test/exec-util';
import { mocked } from '../../../test/util';
import { GlobalConfig } from '../../config/global';
import type { RepoGlobalConfig } from '../../config/types';
import * as _datasource from '../../datasource';
import * as docker from '../../util/exec/docker';
import * as _env from '../../util/exec/env';
import type { UpdateArtifactsConfig } from '../types';
import * as helmv3 from './artifacts';

jest.mock('fs-extra');
jest.mock('child_process');
jest.mock('../../datasource');
jest.mock('../../util/exec/env');
jest.mock('../../util/http');

const datasource = mocked(_datasource);

const fs: jest.Mocked<typeof _fs> = _fs as any;
const exec: jest.Mock<typeof _exec> = _exec as any;
const env = mocked(_env);
Expand Down Expand Up @@ -125,6 +129,9 @@ describe('manager/helmv3/artifacts', () => {
fs.readFile.mockResolvedValueOnce('Old Chart.lock' as never);
const execSnapshots = mockExecAll(exec);
fs.readFile.mockResolvedValueOnce('New Chart.lock' as never);
datasource.getPkgReleases.mockResolvedValueOnce({
releases: [{ version: 'v3.7.2' }],
});
const updatedDeps = [{ depName: 'dep1' }];
expect(
await helmv3.updateArtifacts({
Expand Down Expand Up @@ -199,6 +206,9 @@ describe('manager/helmv3/artifacts', () => {
fs.readFile.mockResolvedValueOnce('Old Chart.lock' as never);
const execSnapshots = mockExecAll(exec);
fs.readFile.mockResolvedValueOnce('New Chart.lock' as never);
datasource.getPkgReleases.mockResolvedValueOnce({
releases: [{ version: 'v3.7.2' }],
});
expect(
await helmv3.updateArtifacts({
packageFileName: 'Chart.yaml',
Expand Down
27 changes: 17 additions & 10 deletions lib/manager/helmv3/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { quote } from 'shlex';
import { TEMPORARY_ERROR } from '../../constants/error-messages';
import { logger } from '../../logger';
import { exec } from '../../util/exec';
import type { ExecOptions } from '../../util/exec/types';
import type { ExecOptions, ToolConstraint } from '../../util/exec/types';
import {
getSiblingFileName,
getSubDirectory,
Expand All @@ -12,17 +12,10 @@ import {
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';

async function helmCommands(
execOptions: ExecOptions,
manifestPath: string,
aliases?: Record<string, string>
): Promise<void> {
const execOptions: ExecOptions = {
docker: {
image: 'helm',
},
extraEnv: {
HELM_EXPERIMENTAL_OCI: '1',
},
};
const cmd = [];

if (aliases) {
Expand Down Expand Up @@ -62,7 +55,21 @@ export async function updateArtifacts({
try {
await writeLocalFile(packageFileName, newPackageFileContent);
logger.debug('Updating ' + lockFileName);
await helmCommands(packageFileName, config.aliases);
const helmToolConstraint: ToolConstraint = {
toolName: 'helm',
constraint: config.constraints?.helm,
};

const execOptions: ExecOptions = {
docker: {
image: 'sidecar',
},
extraEnv: {
HELM_EXPERIMENTAL_OCI: '1',
},
toolConstraints: [helmToolConstraint],
};
await helmCommands(execOptions, packageFileName, config.aliases);
logger.debug('Returning updated Chart.lock');
const newHelmLockContent = await readLocalFile(lockFileName);
if (existingLockFileContent === newHelmLockContent) {
Expand Down
5 changes: 5 additions & 0 deletions lib/util/exec/buildpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const allToolConfig: Record<string, ToolConfig> = {
depName: 'composer/composer',
versioning: composerVersioningId,
},
helm: {
datasource: 'github-releases',
depName: 'helm/helm',
versioning: semverVersioningId,
},
jb: {
datasource: 'github-releases',
depName: 'jsonnet-bundler/jsonnet-bundler',
Expand Down

0 comments on commit bb311cd

Please sign in to comment.