mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
refactor: add pinDigests configuration option for docker (#1033)
This commit is contained in:
parent
db05a259e0
commit
7dd8bf13be
3 changed files with 44 additions and 24 deletions
|
@ -92,6 +92,7 @@ $ node renovate --help
|
||||||
--package-files <list> Package file paths
|
--package-files <list> Package file paths
|
||||||
--ignore-paths <list> Skip any package.json whose path matches one of these.
|
--ignore-paths <list> Skip any package.json whose path matches one of these.
|
||||||
--ignore-deps <list> Dependencies to ignore
|
--ignore-deps <list> Dependencies to ignore
|
||||||
|
--pin-digests [boolean] Whether to add digests to Dockerfile source images
|
||||||
--pin-versions [boolean] Convert ranged versions in package.json to pinned versions
|
--pin-versions [boolean] Convert ranged versions in package.json to pinned versions
|
||||||
--separate-major-releases [boolean] If set to false, it will upgrade dependencies to latest release only, and not separate major/minor branches
|
--separate-major-releases [boolean] If set to false, it will upgrade dependencies to latest release only, and not separate major/minor branches
|
||||||
--separate-patch-releases [boolean] If set to true, it will separate minor and patch updates into separate branches
|
--separate-patch-releases [boolean] If set to true, it will separate minor and patch updates into separate branches
|
||||||
|
@ -458,6 +459,14 @@ Obviously, you can't set repository or package file location with this method.
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><td>
|
<td><td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>`pinDigests`</td>
|
||||||
|
<td>Whether to add digests to Dockerfile source images</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td><pre>true</pre></td>
|
||||||
|
<td>`RENOVATE_PIN_DIGESTS`</td>
|
||||||
|
<td>`--pin-digests`<td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>`pinVersions`</td>
|
<td>`pinVersions`</td>
|
||||||
<td>Convert ranged versions in package.json to pinned versions</td>
|
<td>Convert ranged versions in package.json to pinned versions</td>
|
||||||
|
|
|
@ -315,6 +315,12 @@ const options = [
|
||||||
env: false,
|
env: false,
|
||||||
},
|
},
|
||||||
// Version behaviour
|
// Version behaviour
|
||||||
|
{
|
||||||
|
name: 'pinDigests',
|
||||||
|
description: 'Whether to add digests to Dockerfile source images',
|
||||||
|
stage: 'package',
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'pinVersions',
|
name: 'pinVersions',
|
||||||
description: 'Convert ranged versions in package.json to pinned versions',
|
description: 'Convert ranged versions in package.json to pinned versions',
|
||||||
|
|
|
@ -5,29 +5,34 @@ module.exports = {
|
||||||
};
|
};
|
||||||
|
|
||||||
async function renovateDockerImage(config) {
|
async function renovateDockerImage(config) {
|
||||||
const newDigest = await dockerApi.getDigest(
|
const { currentTag, logger } = config;
|
||||||
config.depName,
|
const upgrades = [];
|
||||||
config.currentTag,
|
if (config.pinDigests) {
|
||||||
config.logger
|
logger.debug('Checking Docker pinDigests');
|
||||||
);
|
const newDigest = await dockerApi.getDigest(
|
||||||
if (!newDigest || config.currentDigest === newDigest) {
|
config.depName,
|
||||||
return [];
|
currentTag,
|
||||||
|
config.logger
|
||||||
|
);
|
||||||
|
if (newDigest && config.currentDigest !== newDigest) {
|
||||||
|
const upgrade = {};
|
||||||
|
upgrade.newTag = currentTag;
|
||||||
|
upgrade.newDigest = newDigest;
|
||||||
|
upgrade.newVersion = newDigest;
|
||||||
|
upgrade.newFrom = config.depName;
|
||||||
|
if (upgrade.newTag) {
|
||||||
|
upgrade.newFrom += `:${upgrade.newTag}`;
|
||||||
|
}
|
||||||
|
upgrade.newFrom += `@${upgrade.newDigest}`;
|
||||||
|
if (config.currentDigest) {
|
||||||
|
upgrade.type = 'digest';
|
||||||
|
upgrade.isDigest = true;
|
||||||
|
} else {
|
||||||
|
upgrade.type = 'pin';
|
||||||
|
upgrade.isPin = true;
|
||||||
|
}
|
||||||
|
upgrades.push(upgrade);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const upgrade = {};
|
return upgrades;
|
||||||
upgrade.newTag = config.currentTag;
|
|
||||||
upgrade.newDigest = newDigest;
|
|
||||||
upgrade.newVersion = newDigest;
|
|
||||||
upgrade.newFrom = config.depName;
|
|
||||||
if (upgrade.newTag) {
|
|
||||||
upgrade.newFrom += `:${upgrade.newTag}`;
|
|
||||||
}
|
|
||||||
upgrade.newFrom += `@${upgrade.newDigest}`;
|
|
||||||
if (config.currentDigest) {
|
|
||||||
upgrade.type = 'digest';
|
|
||||||
upgrade.isDigest = true;
|
|
||||||
} else {
|
|
||||||
upgrade.type = 'pin';
|
|
||||||
upgrade.isPin = true;
|
|
||||||
}
|
|
||||||
return [upgrade];
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue