mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
ff19fb4478
Follow up to #2434, this lets Renovate actually update those image lines
29 lines
905 B
JavaScript
29 lines
905 B
JavaScript
const { getNewFrom } = require('../dockerfile/update');
|
|
|
|
module.exports = {
|
|
updateDependency,
|
|
};
|
|
|
|
function updateDependency(fileContent, upgrade) {
|
|
try {
|
|
const newFrom = getNewFrom(upgrade);
|
|
logger.debug(`kubernetes.updateDependency(): ${newFrom}`);
|
|
const lines = fileContent.split('\n');
|
|
const lineToChange = lines[upgrade.lineNumber];
|
|
const imageLine = new RegExp(/^(\s*-?\s*image:\s*'?"?)[^\s'"]+('?"?\s*)$/);
|
|
if (!lineToChange.match(imageLine)) {
|
|
logger.debug('No image line found');
|
|
return null;
|
|
}
|
|
const newLine = lineToChange.replace(imageLine, `$1${newFrom}$2`);
|
|
if (newLine === lineToChange) {
|
|
logger.debug('No changes necessary');
|
|
return fileContent;
|
|
}
|
|
lines[upgrade.lineNumber] = newLine;
|
|
return lines.join('\n');
|
|
} catch (err) {
|
|
logger.info({ err }, 'Error setting new Kubernetes value');
|
|
return null;
|
|
}
|
|
}
|