Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(autoReplace): Correct digest resolution when the replacementName and replacementVersion options are defined #28655

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ssegato81
Copy link

Changes

  • The getDigestConfig variable uses the correct lookupName when it's running a replacement and the replacementName is set

Context

Discussion #27728
Closes #20304

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@rarkins rarkins changed the title fix: Correct digest resolution when the replacementName and replacementVersion options are defined fix(autoReplace): Correct digest resolution when the replacementName and replacementVersion options are defined Apr 25, 2024
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs tests

// If the present contains the replacementName option and this update executes the replacement
// uses the correct lookupname based on the new replacementName, otherwise it keeps the origina one
if (update.updateType === 'replacement' && config.replacementName) {
getDigestConfig.lookupName = config.replacementName.substring(config.replacementName.indexOf("/") + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks wrong to me. why the substring ?

@viceice viceice marked this pull request as draft April 26, 2024 10:44
@ssegato81
Copy link
Author

ssegato81 commented Apr 26, 2024

needs tests

It already has a test case for that part of the code. You can see it here

it('handles replacements - name only with pinDigests enabled', async () => {

I'm only improving one part of the code that fails when the replacementName option points to another image different from the original one. The test case didn't detect that error/unexpected result because it happens when the lookupUpdates function calls the getDigestConfig one with the wrong values and you are mocking that answer. I don't know if you are expecting something different.

@viceice
Copy link
Member

viceice commented Apr 29, 2024

you can do expectations on the function call, so it's called with the right parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker: Replacement causes existing dependencies to use wrong digest
2 participants