feat: kustomize: support newName in image (#7356)

This commit is contained in:
Dominykas Blyžė 2020-09-23 22:24:40 +03:00 committed by GitHub
parent 9fe6b99d9c
commit 27a280ff81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 17 deletions

View file

@ -15,3 +15,6 @@ images:
newTag: v0.0.2 newTag: v0.0.2
- name: gitlab.com/org/suborg/image - name: gitlab.com/org/suborg/image
newTag: v0.0.3 newTag: v0.0.3
- name: this-lives/on-docker-hub
newName: but.this.lives.on.local/private-registry # and therefore we need to check the versions available here
newTag: v0.0.4

View file

@ -79,25 +79,26 @@ Array [
"currentValue": "v0.1.0", "currentValue": "v0.1.0",
"datasource": "docker", "datasource": "docker",
"depName": "node", "depName": "node",
"lookupName": "node",
}, },
Object { Object {
"currentValue": "v0.0.1", "currentValue": "v0.0.1",
"datasource": "docker", "datasource": "docker",
"depName": "group/instance", "depName": "group/instance",
"lookupName": "group/instance",
}, },
Object { Object {
"currentValue": "v0.0.2", "currentValue": "v0.0.2",
"datasource": "docker", "datasource": "docker",
"depName": "quay.io/test/repo", "depName": "quay.io/test/repo",
"lookupName": "quay.io/test/repo",
}, },
Object { Object {
"currentValue": "v0.0.3", "currentValue": "v0.0.3",
"datasource": "docker", "datasource": "docker",
"depName": "gitlab.com/org/suborg/image", "depName": "gitlab.com/org/suborg/image",
"lookupName": "gitlab.com/org/suborg/image", },
Object {
"currentValue": "v0.0.4",
"datasource": "docker",
"depName": "but.this.lives.on.local/private-registry",
}, },
] ]
`; `;

View file

@ -130,10 +130,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0', currentValue: 'v1.0.0',
datasource: datasourceDocker.id, datasource: datasourceDocker.id,
depName: 'node', depName: 'node',
lookupName: 'node',
}; };
const pkg = extractImage({ const pkg = extractImage({
name: sample.lookupName, name: sample.depName,
newTag: sample.currentValue, newTag: sample.currentValue,
}); });
expect(pkg).toEqual(sample); expect(pkg).toEqual(sample);
@ -143,10 +142,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0', currentValue: 'v1.0.0',
datasource: datasourceDocker.id, datasource: datasourceDocker.id,
depName: 'test/node', depName: 'test/node',
lookupName: 'test/node',
}; };
const pkg = extractImage({ const pkg = extractImage({
name: sample.lookupName, name: sample.depName,
newTag: sample.currentValue, newTag: sample.currentValue,
}); });
expect(pkg).toEqual(sample); expect(pkg).toEqual(sample);
@ -156,10 +154,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0', currentValue: 'v1.0.0',
datasource: datasourceDocker.id, datasource: datasourceDocker.id,
depName: 'quay.io/repo/image', depName: 'quay.io/repo/image',
lookupName: 'quay.io/repo/image',
}; };
const pkg = extractImage({ const pkg = extractImage({
name: sample.lookupName, name: sample.depName,
newTag: sample.currentValue, newTag: sample.currentValue,
}); });
expect(pkg).toEqual(sample); expect(pkg).toEqual(sample);
@ -169,10 +166,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0', currentValue: 'v1.0.0',
datasource: datasourceDocker.id, datasource: datasourceDocker.id,
depName: 'localhost:5000/repo/image', depName: 'localhost:5000/repo/image',
lookupName: 'localhost:5000/repo/image',
}; };
const pkg = extractImage({ const pkg = extractImage({
name: sample.lookupName, name: sample.depName,
newTag: sample.currentValue, newTag: sample.currentValue,
}); });
expect(pkg).toEqual(sample); expect(pkg).toEqual(sample);
@ -182,10 +178,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0', currentValue: 'v1.0.0',
datasource: datasourceDocker.id, datasource: datasourceDocker.id,
depName: 'localhost:5000/repo/image/service', depName: 'localhost:5000/repo/image/service',
lookupName: 'localhost:5000/repo/image/service',
}; };
const pkg = extractImage({ const pkg = extractImage({
name: sample.lookupName, name: sample.depName,
newTag: sample.currentValue, newTag: sample.currentValue,
}); });
expect(pkg).toEqual(sample); expect(pkg).toEqual(sample);
@ -222,7 +217,7 @@ describe('manager/kustomize/extract', () => {
it('should extract out image versions', () => { it('should extract out image versions', () => {
const res = extractPackageFile(gitImages); const res = extractPackageFile(gitImages);
expect(res.deps).toMatchSnapshot(); expect(res.deps).toMatchSnapshot();
expect(res.deps).toHaveLength(4); expect(res.deps).toHaveLength(5);
expect(res.deps[0].currentValue).toEqual('v0.1.0'); expect(res.deps[0].currentValue).toEqual('v0.1.0');
expect(res.deps[1].currentValue).toEqual('v0.0.1'); expect(res.deps[1].currentValue).toEqual('v0.0.1');
}); });

View file

@ -8,6 +8,7 @@ import { PackageDependency, PackageFile } from '../common';
interface Image { interface Image {
name: string; name: string;
newTag: string; newTag: string;
newName?: string;
} }
interface Kustomize { interface Kustomize {
@ -65,8 +66,7 @@ export function extractImage(image: Image): PackageDependency | null {
if (image?.name && image.newTag) { if (image?.name && image.newTag) {
return { return {
datasource: datasourceDocker.id, datasource: datasourceDocker.id,
depName: image.name, depName: image.newName ?? image.name,
lookupName: image.name,
currentValue: image.newTag, currentValue: image.newTag,
}; };
} }