Skip to content

Commit

Permalink
fix(manager:dockerfile): wrong replace with trimmed images (#11485)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Aug 30, 2021
1 parent c8c8684 commit 47dfc83
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/manager/dockerfile/__snapshots__/extract.spec.ts.snap
Expand Up @@ -346,6 +346,22 @@ Array [
]
`;

exports[`manager/dockerfile/extract extractPackageFile() handles prefixes 1`] = `
Array [
Object {
"autoReplaceStringTemplate": "{{lookupName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "18.04",
"datasource": "docker",
"depName": "ubuntu",
"depType": "final",
"lookupName": "amd64/ubuntu",
"replaceString": "amd64/ubuntu:18.04",
"versioning": "ubuntu",
},
]
`;

exports[`manager/dockerfile/extract extractPackageFile() handles quay hosts with port 1`] = `
Object {
"autoReplaceStringTemplate": "{{lookupName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
Expand Down
14 changes: 14 additions & 0 deletions lib/manager/dockerfile/extract.spec.ts
Expand Up @@ -265,6 +265,20 @@ describe('manager/dockerfile/extract', () => {
},
]);
});

it('handles prefixes', () => {
const res = extractPackageFile('FROM amd64/ubuntu:18.04\n').deps;
expect(res).toMatchSnapshot([
{
currentValue: '18.04',
depName: 'ubuntu',
lookupName: 'amd64/ubuntu',
versioning: 'ubuntu',
autoReplaceStringTemplate:
'{{lookupName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
},
]);
});
});
describe('getDep()', () => {
it('rejects null', () => {
Expand Down
4 changes: 4 additions & 0 deletions lib/manager/dockerfile/extract.ts
Expand Up @@ -58,6 +58,10 @@ export function getDep(
if (dep.depName.startsWith(`${prefix}/`)) {
dep.lookupName = dep.depName;
dep.depName = dep.depName.replace(`${prefix}/`, '');
if (specifyReplaceString) {
dep.autoReplaceStringTemplate =
'{{lookupName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}';
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/droneci/__snapshots__/extract.spec.ts.snap
Expand Up @@ -12,7 +12,7 @@ Array [
"replaceString": "elixir:1.8.1-alpine",
},
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"autoReplaceStringTemplate": "{{lookupName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": "sha256:36adc17e9cceab32179d3314da9cb9c737ffb11f0de4e688f407ad6d9ca32201",
"currentValue": "10.0.0",
"datasource": "docker",
Expand Down

0 comments on commit 47dfc83

Please sign in to comment.