remotes: add FetcherByDigest for fetching blobs without foreknown descriptors (useful for general-purpose CAS)#7460
Merged
dmcgowan merged 2 commits intocontainerd:mainfrom Nov 4, 2022
Conversation
FetcherByDigest for fetching blobs without foreknown descriptorsFetcherByDigest for fetching blobs without foreknown descriptors (useful for general-purpose CAS)
f0d6ca8 to
33089d2
Compare
samuelkarp
reviewed
Oct 7, 2022
samuelkarp
approved these changes
Oct 7, 2022
Member
samuelkarp
left a comment
There was a problem hiding this comment.
LGTM. Not merging immediately since I think @dmcgowan might have thoughts on this too.
0fd4097 to
a15d6d6
Compare
Member
Author
dmcgowan
reviewed
Oct 27, 2022
| // FetcherByDigest fetches content by the digest. | ||
| type FetcherByDigest interface { | ||
| // FetchByDigest the resource identified by the digest. | ||
| FetchByDigest(ctx context.Context, dgst digest.Digest) (io.ReadCloser, int64, error) |
Member
There was a problem hiding this comment.
Returning ocispec.Descriptor would be useful here over just int64. The media type could always be application/octet-stream since it was not fetched with any known/trusted context. Annotations could also be set to include the media type returned by the registry. Generally though we use the Descriptor type for blob metadata, I don't lacking a media types makes that less useful here.
Member
Author
There was a problem hiding this comment.
Updated to return the desc with application/octet-stream
a15d6d6 to
974596d
Compare
dmcgowan
reviewed
Nov 3, 2022
…criptors Fetching blobs without foreknown descriptors is useful for using a registry as a general-purpose CAS. Related: `oras blob fetch` (ORAS v0.15.0) Signed-off-by: Akihiro Suda <[email protected]>
e.g., `ctr content fetch-blob docker.io/library/debian:latest sha256:43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a` Signed-off-by: Akihiro Suda <[email protected]>
974596d to
11a06c1
Compare
dmcgowan
approved these changes
Nov 4, 2022
This was referenced Feb 25, 2023
This was referenced Mar 8, 2023
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.
Fetching blobs without foreknown descriptors is useful for using a registry as a general-purpose CAS.
Related:
oras blob fetch(ORAS v0.15.0)Go interface
ctrcommand$ ctr content fetch-blob docker.io/library/debian:latest sha256:43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a {"architecture":"amd64","config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["bash"],"Image":"sha256:357a26ba6784f85d683e053559f71c9c8783306e53526fbe8c481eb203845b22","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null},"container":"926ed85caba06d6ce5919fdab3eae1de98be1fddf12f7126bdcbcc79840861d5","container_config":{"Hostname":"926ed85caba0","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","#(nop) ","CMD [\"bash\"]"],"Image":"sha256:357a26ba6784f85d683e053559f71c9c8783306e53526fbe8c481eb203845b22","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{}},"created":"2022-09-13T00:56:19.369186372Z","docker_version":"20.10.12","history":[{"created":"2022-09-13T00:56:18.878860216Z","created_by":"/bin/sh -c #(nop) ADD file:ff01c6dedb67cf22e9b0735e099b9b6367770c4880941862cc7ec0e979b4118b in / "},{"created":"2022-09-13T00:56:19.369186372Z","created_by":"/bin/sh -c #(nop) CMD [\"bash\"]","empty_layer":true}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:b9fcb0f781e4bcde2c9f7f27cb93c549f6c6ecfdc7fdcc783813347e97faf19c"]}}The tag part in the ref string is dummy, so
ctr content fetch-blob docker.io/library/debian:dummy@sha256:0000000000000000000000000000000000000000000000000000000000000000 sha256:43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1areturns the same result too.