mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat(kustomize): Add support for bases defined in the resources block (#6328)
This commit is contained in:
parent
a416dab34a
commit
d62415e955
4 changed files with 47 additions and 1 deletions
14
lib/manager/kustomize/__fixtures__/depsInResources.yaml
Normal file
14
lib/manager/kustomize/__fixtures__/depsInResources.yaml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
namespace: testing-namespace
|
||||||
|
|
||||||
|
bases:
|
||||||
|
- git@github.com:moredhel/remote-kustomize.git?ref=v0.0.1
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- github.com/fluxcd/flux/deploy?ref=1.19.0
|
||||||
|
|
||||||
|
images:
|
||||||
|
- name: nginx
|
|
@ -56,6 +56,23 @@ Array [
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`manager/kustomize/extract extractPackageFile() should extract bases from bases block and the resources block 1`] = `
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"currentValue": "v0.0.1",
|
||||||
|
"datasource": "git-tags",
|
||||||
|
"depName": "git@github.com:moredhel/remote-kustomize.git",
|
||||||
|
"lookupName": "git@github.com:moredhel/remote-kustomize.git",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "1.19.0",
|
||||||
|
"datasource": "github-tags",
|
||||||
|
"depName": "fluxcd/flux/deploy",
|
||||||
|
"lookupName": "fluxcd/flux",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`manager/kustomize/extract extractPackageFile() should extract out image versions 1`] = `
|
exports[`manager/kustomize/extract extractPackageFile() should extract out image versions 1`] = `
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
|
|
|
@ -44,6 +44,11 @@ const gitImages = readFileSync(
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const kustomizeDepsInResources = readFileSync(
|
||||||
|
'lib/manager/kustomize/__fixtures__/depsInResources.yaml',
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
|
||||||
describe('manager/kustomize/extract', () => {
|
describe('manager/kustomize/extract', () => {
|
||||||
it('should successfully parse a valid kustomize file', () => {
|
it('should successfully parse a valid kustomize file', () => {
|
||||||
const file = parseKustomize(kustomizeGitSSHBase);
|
const file = parseKustomize(kustomizeGitSSHBase);
|
||||||
|
@ -227,5 +232,15 @@ describe('manager/kustomize/extract', () => {
|
||||||
it('does nothing with kustomize empty kustomize files', () => {
|
it('does nothing with kustomize empty kustomize files', () => {
|
||||||
expect(extractPackageFile(kustomizeEmpty)).toBeNull();
|
expect(extractPackageFile(kustomizeEmpty)).toBeNull();
|
||||||
});
|
});
|
||||||
|
it('should extract bases from bases block and the resources block', () => {
|
||||||
|
const res = extractPackageFile(kustomizeDepsInResources);
|
||||||
|
expect(res).not.toBeNull();
|
||||||
|
expect(res.deps).toMatchSnapshot();
|
||||||
|
expect(res.deps).toHaveLength(2);
|
||||||
|
expect(res.deps[0].currentValue).toEqual('v0.0.1');
|
||||||
|
expect(res.deps[1].currentValue).toEqual('1.19.0');
|
||||||
|
expect(res.deps[1].depName).toEqual('fluxcd/flux/deploy');
|
||||||
|
expect(res.deps[1].lookupName).toEqual('fluxcd/flux');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,7 +90,7 @@ export function parseKustomize(content: string): Kustomize | null {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg.bases = pkg.bases || [];
|
pkg.bases = (pkg.bases || []).concat(pkg.resources || []);
|
||||||
pkg.images = pkg.images || [];
|
pkg.images = pkg.images || [];
|
||||||
|
|
||||||
return pkg;
|
return pkg;
|
||||||
|
|
Loading…
Reference in a new issue