mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
feat(droneci): Preserve multiline image with digest format (#15673)
This commit is contained in:
parent
2de0acd6d3
commit
a5b26f6a97
2 changed files with 34 additions and 23 deletions
|
@ -40,7 +40,7 @@ Array [
|
||||||
"replaceString": "redis:alpine",
|
"replaceString": "redis:alpine",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"autoReplaceStringTemplate": "{{packageName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
|
"autoReplaceStringTemplate": "\\"{{packageName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}\\\\\n @{{newDigest}}{{/if}}\\"",
|
||||||
"currentDigest": "sha256:36adc17e9cceab32179d3314da9cb9c737ffb11f0de4e688f407ad6d9ca32201",
|
"currentDigest": "sha256:36adc17e9cceab32179d3314da9cb9c737ffb11f0de4e688f407ad6d9ca32201",
|
||||||
"currentValue": "10.0.0",
|
"currentValue": "10.0.0",
|
||||||
"datasource": "docker",
|
"datasource": "docker",
|
||||||
|
@ -51,7 +51,7 @@ Array [
|
||||||
@sha256:36adc17e9cceab32179d3314da9cb9c737ffb11f0de4e688f407ad6d9ca32201\\\"",
|
@sha256:36adc17e9cceab32179d3314da9cb9c737ffb11f0de4e688f407ad6d9ca32201\\\"",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"autoReplaceStringTemplate": "{{packageName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
|
"autoReplaceStringTemplate": "\\"{{packageName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}\\\\\n @{{newDigest}}{{/if}}\\"",
|
||||||
"currentDigest": "sha256:36adc17e9cceab32179d3314da9cb9c737ffb11f0de4e688f407ad6d9ca32201",
|
"currentDigest": "sha256:36adc17e9cceab32179d3314da9cb9c737ffb11f0de4e688f407ad6d9ca32201",
|
||||||
"currentValue": "10.0.0",
|
"currentValue": "10.0.0",
|
||||||
"datasource": "docker",
|
"datasource": "docker",
|
||||||
|
|
|
@ -10,40 +10,51 @@ export function extractPackageFile(content: string): PackageFile | null {
|
||||||
for (let lineNumber = 0; lineNumber < lines.length; lineNumber += 1) {
|
for (let lineNumber = 0; lineNumber < lines.length; lineNumber += 1) {
|
||||||
const line = lines[lineNumber];
|
const line = lines[lineNumber];
|
||||||
|
|
||||||
const first_line_match = regEx(/^\s* image:\s*(['"]([^\s'"]+)\\)$/).exec(
|
const firstLineMatch = regEx(
|
||||||
line
|
/^(?<leading>\s* image:\s*)(?<replaceString>['"](?<currentFrom>[^\s'"]+)\\)$/
|
||||||
);
|
).exec(line);
|
||||||
if (first_line_match) {
|
|
||||||
let currentFrom = first_line_match[2];
|
if (firstLineMatch?.groups) {
|
||||||
let replaceString = first_line_match[1];
|
let currentFrom = firstLineMatch.groups.currentFrom;
|
||||||
|
let replaceString = firstLineMatch.groups.replaceString;
|
||||||
|
|
||||||
for (let i = lineNumber + 1; i < lines.length; i += 1) {
|
for (let i = lineNumber + 1; i < lines.length; i += 1) {
|
||||||
const internal_line = lines[i];
|
const internalLine = lines[i];
|
||||||
const middle_line_match =
|
const middleLineMatch = regEx(
|
||||||
regEx(/^(\s*([^\s'"]+)\\)$/).exec(internal_line);
|
/^(?<replaceString>\s*(?<currentFrom>[^\s'"]+)\\)$/
|
||||||
if (middle_line_match) {
|
).exec(internalLine);
|
||||||
currentFrom += middle_line_match[2];
|
if (middleLineMatch?.groups) {
|
||||||
replaceString += '\n' + middle_line_match[1];
|
currentFrom += middleLineMatch.groups.currentFrom;
|
||||||
|
replaceString += '\n' + middleLineMatch.groups.replaceString;
|
||||||
} else {
|
} else {
|
||||||
const final_line_match = regEx(/^(\s*([^\s'"]+)['"])$/).exec(
|
const finalLineMatch = regEx(
|
||||||
internal_line
|
/^(?<replaceString>\s*(?<currentFrom>[^\s'"]+)['"])$/
|
||||||
);
|
).exec(internalLine);
|
||||||
if (final_line_match) {
|
if (finalLineMatch?.groups) {
|
||||||
currentFrom += final_line_match[2];
|
currentFrom += finalLineMatch.groups.currentFrom;
|
||||||
replaceString += '\n' + final_line_match[1];
|
replaceString += '\n' + finalLineMatch.groups.replaceString;
|
||||||
|
|
||||||
const dep = getDep(currentFrom);
|
const dep = getDep(currentFrom);
|
||||||
dep.depType = 'docker';
|
dep.depType = 'docker';
|
||||||
dep.replaceString = replaceString;
|
dep.replaceString = replaceString;
|
||||||
|
if (dep.autoReplaceStringTemplate) {
|
||||||
|
const d = '@{{newDigest}}';
|
||||||
|
const c = firstLineMatch.groups.leading.length + 1;
|
||||||
|
const nd = `\\\n${' '.repeat(c)}${d}`;
|
||||||
|
const replaced = dep.autoReplaceStringTemplate.replace(d, nd);
|
||||||
|
dep.autoReplaceStringTemplate = `"${replaced}"`;
|
||||||
|
}
|
||||||
deps.push(dep);
|
deps.push(dep);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const match = regEx(/^\s* image:\s*'?"?([^\s'"]+)'?"?\s*$/).exec(line);
|
const match = regEx(
|
||||||
if (match) {
|
/^\s* image:\s*'?"?(?<currentFrom>[^\s'"]+)'?"?\s*$/
|
||||||
const dep = getDep(match[1]);
|
).exec(line);
|
||||||
|
if (match?.groups) {
|
||||||
|
const dep = getDep(match.groups.currentFrom);
|
||||||
dep.depType = 'docker';
|
dep.depType = 'docker';
|
||||||
deps.push(dep);
|
deps.push(dep);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue