mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
fix(docker): ensure digest is updated only once with ARG and multiple FROM statements (#18061)
This commit is contained in:
committed by
GitHub
parent
b18afff568
commit
be21d44700
@@ -750,13 +750,13 @@ describe('modules/manager/dockerfile/extract', () => {
|
||||
expect(res).toEqual([
|
||||
{
|
||||
autoReplaceStringTemplate:
|
||||
'FROM nginx:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}${patch1}$patch2',
|
||||
'FROM nginx:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}${patch1}$patch2\n',
|
||||
currentDigest: undefined,
|
||||
currentValue: '1.20',
|
||||
datasource: 'docker',
|
||||
depName: 'nginx',
|
||||
depType: 'final',
|
||||
replaceString: 'FROM nginx:1.20${patch1}$patch2',
|
||||
replaceString: 'FROM nginx:1.20${patch1}$patch2\n',
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -770,13 +770,13 @@ describe('modules/manager/dockerfile/extract', () => {
|
||||
expect(res).toEqual([
|
||||
{
|
||||
autoReplaceStringTemplate:
|
||||
'ARG\tVARIANT="{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}" ',
|
||||
'ARG\tVARIANT="{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}" \n',
|
||||
currentDigest: undefined,
|
||||
currentValue: '1.60.0-bullseye',
|
||||
datasource: 'docker',
|
||||
depName: 'rust',
|
||||
depType: 'final',
|
||||
replaceString: 'ARG\tVARIANT="1.60.0-bullseye" ',
|
||||
replaceString: 'ARG\tVARIANT="1.60.0-bullseye" \n',
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -790,12 +790,12 @@ describe('modules/manager/dockerfile/extract', () => {
|
||||
expect(res).toEqual([
|
||||
{
|
||||
autoReplaceStringTemplate:
|
||||
'ARG IMAGE_VERSION=${IMAGE_VERSION:-ubuntu:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}}',
|
||||
'ARG IMAGE_VERSION=${IMAGE_VERSION:-ubuntu:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}}\n',
|
||||
currentValue: 'xenial',
|
||||
datasource: 'docker',
|
||||
depName: 'ubuntu',
|
||||
depType: 'final',
|
||||
replaceString: 'ARG IMAGE_VERSION=${IMAGE_VERSION:-ubuntu:xenial}',
|
||||
replaceString: 'ARG IMAGE_VERSION=${IMAGE_VERSION:-ubuntu:xenial}\n',
|
||||
versioning: 'ubuntu',
|
||||
},
|
||||
]);
|
||||
@@ -833,23 +833,23 @@ describe('modules/manager/dockerfile/extract', () => {
|
||||
expect(res).toEqual([
|
||||
{
|
||||
autoReplaceStringTemplate:
|
||||
'ARG base=nginx:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
|
||||
'ARG base=nginx:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}\n',
|
||||
currentDigest: undefined,
|
||||
currentValue: '1.19',
|
||||
datasource: 'docker',
|
||||
depName: 'nginx',
|
||||
depType: 'stage',
|
||||
replaceString: 'ARG base=nginx:1.19',
|
||||
replaceString: 'ARG base=nginx:1.19\n',
|
||||
},
|
||||
{
|
||||
autoReplaceStringTemplate:
|
||||
'ARG base=nginx:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
|
||||
'ARG base=nginx:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}\n',
|
||||
currentDigest: undefined,
|
||||
currentValue: '1.20',
|
||||
datasource: 'docker',
|
||||
depName: 'nginx',
|
||||
depType: 'final',
|
||||
replaceString: 'ARG base=nginx:1.20',
|
||||
replaceString: 'ARG base=nginx:1.20\n',
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -890,7 +890,7 @@ describe('modules/manager/dockerfile/extract', () => {
|
||||
autoReplaceStringTemplate:
|
||||
' ARG \\\n' +
|
||||
'\t# multi-line arg\n' +
|
||||
' ALPINE_VERSION=alpine:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
|
||||
' ALPINE_VERSION=alpine:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}\n',
|
||||
currentDigest: undefined,
|
||||
currentValue: '3.15.4',
|
||||
datasource: 'docker',
|
||||
@@ -899,7 +899,7 @@ describe('modules/manager/dockerfile/extract', () => {
|
||||
replaceString:
|
||||
' ARG \\\n' +
|
||||
'\t# multi-line arg\n' +
|
||||
' ALPINE_VERSION=alpine:3.15.4',
|
||||
' ALPINE_VERSION=alpine:3.15.4\n',
|
||||
},
|
||||
{
|
||||
autoReplaceStringTemplate:
|
||||
@@ -951,7 +951,7 @@ describe('modules/manager/dockerfile/extract', () => {
|
||||
autoReplaceStringTemplate:
|
||||
' ARG `\n' +
|
||||
'\t# multi-line arg\n' +
|
||||
' ALPINE_VERSION=alpine:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
|
||||
' ALPINE_VERSION=alpine:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}\n',
|
||||
currentDigest: undefined,
|
||||
currentValue: '3.15.4',
|
||||
datasource: 'docker',
|
||||
@@ -960,7 +960,7 @@ describe('modules/manager/dockerfile/extract', () => {
|
||||
replaceString:
|
||||
' ARG `\n' +
|
||||
'\t# multi-line arg\n' +
|
||||
' ALPINE_VERSION=alpine:3.15.4',
|
||||
' ALPINE_VERSION=alpine:3.15.4\n',
|
||||
},
|
||||
{
|
||||
autoReplaceStringTemplate:
|
||||
|
||||
@@ -89,6 +89,10 @@ function processDepForAutoReplace(
|
||||
.map((lineNumber) => lines[lineNumber])
|
||||
.join(linefeed);
|
||||
|
||||
if (!dep.currentDigest) {
|
||||
dep.replaceString += linefeed;
|
||||
}
|
||||
|
||||
dep.autoReplaceStringTemplate = getAutoReplaceTemplate(dep);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user