-
Notifications
You must be signed in to change notification settings - Fork 47
image/internal: sha512 support for skopeo copy #475
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
Open
lsm5
wants to merge
2
commits into
containers:main
Choose a base branch
from
lsm5:digest-redux
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+146
−20
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,7 +146,7 @@ func (ref dirReference) NewImage(ctx context.Context, sys *types.SystemContext) | |
| // NewImageSource returns a types.ImageSource for this reference. | ||
| // The caller must call .Close() on the returned ImageSource. | ||
| func (ref dirReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) { | ||
| return newImageSource(ref), nil | ||
| return newImageSource(ref) | ||
| } | ||
|
|
||
| // NewImageDestination returns a types.ImageDestination for this reference. | ||
|
|
@@ -172,12 +172,19 @@ func (ref dirReference) manifestPath(instanceDigest *digest.Digest) (string, err | |
| } | ||
|
|
||
| // layerPath returns a path for a layer tarball within a directory using our conventions. | ||
| func (ref dirReference) layerPath(digest digest.Digest) (string, error) { | ||
| if err := digest.Validate(); err != nil { // digest.Digest.Encoded() panics on failure, and could possibly result in a path with ../, so validate explicitly. | ||
| func (ref dirReference) layerPath(d digest.Digest) (string, error) { | ||
| if err := d.Validate(); err != nil { // digest.Digest.Encoded() panics on failure, and could possibly result in a path with ../, so validate explicitly. | ||
| return "", err | ||
| } | ||
| // FIXME: Should we keep the digest identification? | ||
| return filepath.Join(ref.path, digest.Encoded()), nil | ||
|
|
||
| var filename string | ||
| if d.Algorithm() == digest.Canonical { | ||
| filename = d.Encoded() | ||
| } else { | ||
| filename = d.Algorithm().String() + "-" + d.Encoded() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder whether we need to do a version check and conditionally use the old logic here. I guess that doesn’t matter in practice. |
||
| } | ||
|
|
||
| return filepath.Join(ref.path, filename), nil | ||
| } | ||
|
|
||
| // signaturePath returns a path for a signature within a directory using our conventions. | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the destination-transport-side digest computation must be a more complex logic, see in the earlier PR about the interaction with
cannotModifyManifestReason.… and
dirReference.layerPathdiscards the algorithm name; that does not generalize for other algorithms, we need to move towards agility where adding an extra algorithm is a ~parameter change and does not require any more changes to the “code proper”; i.e. discarding algorithm names is no longer much of an option.(We need to keep the existing file names for
sha256, to retain compatibility. And… do we define a new value forversionPath?!)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated PutBlob to store blob under provided digest algorithm with the algorithm name prepended (except for Canonical) along with a canonical digest hardlink.
Doesn't break existing behaviour but there's new stuff, so maybe we should? I'll defer to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, anyway, readers of
dir:can only start with the manifest, and the values provided in the manifest. So ifPutBlobreturns sha512, and the manifest is written to include sha512, readers will not know the sha256 value and have no way to use it.So I don’t think we need to compute both digests at all; just the
layerPathchanges to the path computation, + some (as-yet-undefined) logic forPutBlobto use “the algorithm the user wanted”, should be sufficient.I think with the changes to
layerPath, we need to. Previously it was, hypothetically, possible to read a complete sha512 image fromdir:, and those images will now break. And we will need to update bothdir…Dest…anddir…Src…: destinations should refuse to work on future versions, and still assign the existing1.1version for sha256 images for maximum compatibility. sources should detect+refuse future versions.Consider making the
dirchanges a separate PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep the dir changes here because of the review comments. Separate PR for image/internal at #486