mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix(helmv3): set helm repositories from aliases to update Chart.lock (#12470)
This commit is contained in:
parent
87011e78ef
commit
a687981810
4 changed files with 178 additions and 4 deletions
|
@ -151,3 +151,123 @@ Array [
|
|||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`manager/helmv3/artifacts sets repositories from aliases 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"file": Object {
|
||||
"contents": "New Chart.lock",
|
||||
"name": "Chart.lock",
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`manager/helmv3/artifacts sets repositories from aliases 2`] = `
|
||||
Array [
|
||||
Object {
|
||||
"cmd": "helm repo add stable the_stable_url",
|
||||
"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",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"cmd": "helm repo add repo1 the_repo1_url",
|
||||
"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",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"cmd": "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",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`manager/helmv3/artifacts sets repositories from aliases with docker 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"file": Object {
|
||||
"contents": "New Chart.lock",
|
||||
"name": "Chart.lock",
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`manager/helmv3/artifacts sets repositories from aliases with docker 2`] = `
|
||||
Array [
|
||||
Object {
|
||||
"cmd": "docker pull renovate/helm",
|
||||
"options": Object {
|
||||
"encoding": "utf-8",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"cmd": "docker ps --filter name=renovate_helm -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 ''\\"",
|
||||
"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",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"LC_ALL": "en_US",
|
||||
"NO_PROXY": "localhost",
|
||||
"PATH": "/tmp/path",
|
||||
},
|
||||
"maxBuffer": 10485760,
|
||||
"timeout": 900000,
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
|
|
@ -148,4 +148,47 @@ describe('manager/helmv3/artifacts', () => {
|
|||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('sets repositories from aliases', async () => {
|
||||
fs.readFile.mockResolvedValueOnce('Old Chart.lock' as never);
|
||||
const execSnapshots = mockExecAll(exec);
|
||||
fs.readFile.mockResolvedValueOnce('New Chart.lock' as never);
|
||||
expect(
|
||||
await helmv3.updateArtifacts({
|
||||
packageFileName: 'Chart.yaml',
|
||||
updatedDeps: [],
|
||||
newPackageFileContent: '{}',
|
||||
config: {
|
||||
...config,
|
||||
updateType: 'lockFileMaintenance',
|
||||
aliases: { stable: 'the_stable_url', repo1: 'the_repo1_url' },
|
||||
},
|
||||
})
|
||||
).toMatchSnapshot([
|
||||
{ file: { contents: 'New Chart.lock', name: 'Chart.lock' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('sets repositories from aliases with docker', async () => {
|
||||
setGlobalConfig({ ...adminConfig, binarySource: 'docker' });
|
||||
fs.readFile.mockResolvedValueOnce('Old Chart.lock' as never);
|
||||
const execSnapshots = mockExecAll(exec);
|
||||
fs.readFile.mockResolvedValueOnce('New Chart.lock' as never);
|
||||
expect(
|
||||
await helmv3.updateArtifacts({
|
||||
packageFileName: 'Chart.yaml',
|
||||
updatedDeps: [],
|
||||
newPackageFileContent: '{}',
|
||||
config: {
|
||||
...config,
|
||||
updateType: 'lockFileMaintenance',
|
||||
aliases: { stable: 'the_stable_url', repo1: 'the_repo1_url' },
|
||||
},
|
||||
})
|
||||
).toMatchSnapshot([
|
||||
{ file: { contents: 'New Chart.lock', name: 'Chart.lock' } },
|
||||
]);
|
||||
expect(execSnapshots).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,9 +10,10 @@ import {
|
|||
} from '../../util/fs';
|
||||
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
|
||||
|
||||
async function helmUpdate(manifestPath: string): Promise<void> {
|
||||
const cmd = `helm dependency update ${quote(getSubDirectory(manifestPath))}`;
|
||||
|
||||
async function helmCommands(
|
||||
manifestPath: string,
|
||||
aliases?: Record<string, string>
|
||||
): Promise<void> {
|
||||
const execOptions: ExecOptions = {
|
||||
docker: {
|
||||
image: 'helm',
|
||||
|
@ -21,6 +22,15 @@ async function helmUpdate(manifestPath: string): Promise<void> {
|
|||
HELM_EXPERIMENTAL_OCI: '1',
|
||||
},
|
||||
};
|
||||
const cmd = [];
|
||||
|
||||
if (aliases) {
|
||||
Object.entries(aliases).forEach(([alias, url]) =>
|
||||
cmd.push(`helm repo add ${quote(alias)} ${quote(url)}`)
|
||||
);
|
||||
}
|
||||
cmd.push(`helm dependency update ${quote(getSubDirectory(manifestPath))}`);
|
||||
|
||||
await exec(cmd, execOptions);
|
||||
}
|
||||
|
||||
|
@ -51,7 +61,7 @@ export async function updateArtifacts({
|
|||
try {
|
||||
await writeLocalFile(packageFileName, newPackageFileContent);
|
||||
logger.debug('Updating ' + lockFileName);
|
||||
await helmUpdate(packageFileName);
|
||||
await helmCommands(packageFileName, config.aliases);
|
||||
logger.debug('Returning updated Chart.lock');
|
||||
const newHelmLockContent = await readLocalFile(lockFileName);
|
||||
if (existingLockFileContent === newHelmLockContent) {
|
||||
|
|
|
@ -49,6 +49,7 @@ export interface UpdateArtifactsConfig {
|
|||
newValue?: string;
|
||||
newVersion?: string;
|
||||
newMajor?: number;
|
||||
aliases?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface RangeConfig<T = Record<string, any>> extends ManagerData<T> {
|
||||
|
|
Loading…
Reference in a new issue