remotes: add FetcherByDigest for fetching blobs without foreknown descriptors (useful for general-purpose CAS)#7460
Conversation
FetcherByDigest for fetching blobs without foreknown descriptorsFetcherByDigest for fetching blobs without foreknown descriptors (useful for general-purpose CAS)
f0d6ca8 to
33089d2
Compare
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
|
Could you take a look? |
remotes/resolver.go
Outdated
| // 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) |
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.
There was a problem hiding this comment.
Updated to return the desc with application/octet-stream
a15d6d6 to
974596d
Compare
…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
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.