Skip to content

Commit

Permalink
fix(lookup): use newValue for digest lookup, not compareValue (#27596)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 28, 2024
1 parent 992527f commit b3c27af
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
21 changes: 21 additions & 0 deletions lib/workers/repository/process/lookup/index.spec.ts
Expand Up @@ -3489,6 +3489,27 @@ describe('workers/repository/process/lookup/index', () => {
lookup.lookupUpdates(config),
).unwrapOrThrow();

expect(getDockerDigest.mock.calls).toEqual([
[
{
currentDigest: 'aaa111',
currentValue: '18.10.0-alpine',
packageName: 'node',
registryUrl: 'https://index.docker.io',
},
'18.19.0-alpine',
],
[
{
currentDigest: 'aaa111',
currentValue: '18.10.0-alpine',
packageName: 'node',
registryUrl: 'https://index.docker.io',
},
'18.10.0-alpine',
],
]);

expect(res).toEqual({
currentVersion: '18.10.0',
fixedVersion: '18.10.0',
Expand Down
39 changes: 20 additions & 19 deletions lib/workers/repository/process/lookup/index.ts
Expand Up @@ -442,14 +442,32 @@ export async function lookupUpdates(
} else if (compareValue && versioning.isSingleVersion(compareValue)) {
res.fixedVersion = compareValue.replace(regEx(/^=+/), '');
}

// massage versionCompatibility
if (
is.string(config.currentValue) &&
is.string(compareValue) &&
is.string(config.versionCompatibility)
) {
for (const update of res.updates) {
logger.debug({ update });
if (is.string(config.currentValue) && is.string(update.newValue)) {
update.newValue = config.currentValue.replace(
compareValue,
update.newValue,
);
}
}
}

// Add digests if necessary
if (supportsDigests(config.datasource)) {
if (config.currentDigest) {
if (!config.digestOneAndOnly || !res.updates.length) {
// digest update
res.updates.push({
updateType: 'digest',
newValue: compareValue,
newValue: config.currentValue,
});
}
} else if (config.pinDigests) {
Expand All @@ -459,7 +477,7 @@ export async function lookupUpdates(
res.updates.push({
isPinDigest: true,
updateType: 'pinDigest',
newValue: compareValue,
newValue: config.currentValue,
});
}
}
Expand Down Expand Up @@ -520,23 +538,6 @@ export async function lookupUpdates(
}
}

// massage versionCompatibility
if (
is.string(config.currentValue) &&
is.string(compareValue) &&
is.string(config.versionCompatibility)
) {
for (const update of res.updates) {
logger.debug({ update });
if (is.string(config.currentValue) && is.string(update.newValue)) {
update.newValue = config.currentValue.replace(
compareValue,
update.newValue,
);
}
}
}

if (res.updates.length) {
delete res.skipReason;
}
Expand Down

0 comments on commit b3c27af

Please sign in to comment.