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
- name: gitlab.com/org/suborg/image
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",
"datasource": "docker",
"depName": "node",
"lookupName": "node",
},
Object {
"currentValue": "v0.0.1",
"datasource": "docker",
"depName": "group/instance",
"lookupName": "group/instance",
},
Object {
"currentValue": "v0.0.2",
"datasource": "docker",
"depName": "quay.io/test/repo",
"lookupName": "quay.io/test/repo",
},
Object {
"currentValue": "v0.0.3",
"datasource": "docker",
"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',
datasource: datasourceDocker.id,
depName: 'node',
lookupName: 'node',
};
const pkg = extractImage({
name: sample.lookupName,
name: sample.depName,
newTag: sample.currentValue,
});
expect(pkg).toEqual(sample);
@ -143,10 +142,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0',
datasource: datasourceDocker.id,
depName: 'test/node',
lookupName: 'test/node',
};
const pkg = extractImage({
name: sample.lookupName,
name: sample.depName,
newTag: sample.currentValue,
});
expect(pkg).toEqual(sample);
@ -156,10 +154,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0',
datasource: datasourceDocker.id,
depName: 'quay.io/repo/image',
lookupName: 'quay.io/repo/image',
};
const pkg = extractImage({
name: sample.lookupName,
name: sample.depName,
newTag: sample.currentValue,
});
expect(pkg).toEqual(sample);
@ -169,10 +166,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0',
datasource: datasourceDocker.id,
depName: 'localhost:5000/repo/image',
lookupName: 'localhost:5000/repo/image',
};
const pkg = extractImage({
name: sample.lookupName,
name: sample.depName,
newTag: sample.currentValue,
});
expect(pkg).toEqual(sample);
@ -182,10 +178,9 @@ describe('manager/kustomize/extract', () => {
currentValue: 'v1.0.0',
datasource: datasourceDocker.id,
depName: 'localhost:5000/repo/image/service',
lookupName: 'localhost:5000/repo/image/service',
};
const pkg = extractImage({
name: sample.lookupName,
name: sample.depName,
newTag: sample.currentValue,
});
expect(pkg).toEqual(sample);
@ -222,7 +217,7 @@ describe('manager/kustomize/extract', () => {
it('should extract out image versions', () => {
const res = extractPackageFile(gitImages);
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[1].currentValue).toEqual('v0.0.1');
});

View file

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