Repository navigation
Conversation
…ulti-arch image Fixes apache#9290
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixes #9290.
When
skopeo inspect --rawreturns a manifest list,get_manifest_from_docker_imagere-fetches the amd64 entry by digest, but built the new reference withimage.split("/", 1)[-1].split(":", 1)[0]. That drops everything before the first/, soregistry.example.com/team/app:1.0becameteam/app@<digest>andmyorg/app:1becameapp@<digest>(i.e.library/appon Docker Hub).Changes:
get_image_without_tag_or_digestthat drops only the tag and/or digest. A:is treated as a tag only if it comes after the last/, so a registry port likelocalhost:5000/appis kept.get_manifest_from_docker_imageuses it for the by-digest re-fetch.How was the change tested
python -m unittest -v test_docker_to_squashinbin/with Python 3.9: passes.test_get_image_without_tag_or_digest(plain names, namespaces, registries with and without a port, digests) and a test that mocksskopeo inspectwith a manifest list and checks the second call isdocker://registry.example.com/team/app@sha256:.... With the fix reverted the second test fails withdocker://team/app@sha256:amd.calculate_string_hash, because it getsstr(out)(a str) andhashlibwon't hash a str on Python 3. Didn't touch that here since it's a separate issue.An AI assistant helped draft this change; I reviewed it and take responsibility for it.