You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Command to fetch a blob from a remote registry #475
Usage:
oras blob fetch REG/REPO@DIGEST [flags]
Flags:
--ca-file string server certificate authority file for the remote registry
-d, --debug debug mode
--descriptor only fetch a descriptor of the blob
-h, --help help for fetching a blob
--insecure allow connections to SSL registry without certs
-p, --password string registry password or identity token
--password-stdin read password or identity token from stdin
--plain-http allow insecure connections to registry without SSL check
-u, --username string registry username
-v, --verbose verbose output
-o, --output string save the fetched blob to a local file
crane blob zoeycr0707.azurecr.io/hello-world:linuxarmv5@sha256:b921b04d0447ddcd82a9220d887cd146f6ef39e20a938ee5e19a90fc3323e030 > blob.tar.gz
Will save the blob output to the blob.tar.gz
crane blob zoeycr0707.azurecr.io/hello-world:linuxarmv5@sha256:b921b04d0447ddcd82a9220d887cd146f6ef39e20a938ee5e19a90fc3323e030
Will print the output.
If the blob is a config, output will be like:
For oras fetch blob workflow, I am wondering how should we design the UX. Should we set the output (--output) as an optional flag or should we require users to provide output path since most of the blobs are not readable?
Thanks @lizMSFT for driving this UX discussion. My thoughts are
Printing out a blob can be a valuable feature to user, e.g. when running oras blob fetch mcr.microsoft.com/mcr/hello-world@sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e user might want to only view the config content without saving it to a file.
We should avoid printing out a unprintable blob. We can borrow the UX from curl like below:
$ curl https://mcr.microsoft.com/v2/mcr/hello-world/blobs/sha256:1b930d010525941c1d56ec53b97bd057a67ae1865eebf042686d2a2d18271ced -L
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
I agree with @qweeah 's thoughts and I want to share two typical scenarios. To fetch a specific sha256 blob from a remote registry, there are two typical types of blob that users will request to:
a. JSON
b. Tar layer
If users are requesting a JSON blob, it returns it to stdout:
If users are requesting a tar layer blob that is unreadable, it can prompt users that it is unreadable and will generate a file.
$ oras blob fetch localhost:hello-world@sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e
Warning: This blob is an unreadable binary file that can mess up your terminal. You can add the flag "--output" to save it locally.
Blobs are intended to be binaries with garbled characters. Except config blobs, they are most likely to be non-printable. Since ORAS focuses more on artifacts where artifact manifest does not leverage configs, it does not make sense to print non-printable blobs by default.
Therefore, I’d like to always have an --output parameter to write the blob, and save stdout for printing progress status.
Of course, we need a curl-like --output - to output to stdout.
Use an optional --output flag: oras blob fetch localhost:5000@digest
Either --output or --descriptor MUST be provided, or provide both of them. Otherwise will return error, e.g.,
oras blob fetch localhost:5000@digest --output blob.tar.gz // `stdout` for printing progress status, and save the blob content to the local file
Fetched localhost:hello-world@digest
Save to file: blob.tar.gz
oras blob fetch localhost:5000@digest --descriptor // `stdout` for printing the descriptor
{"MediaType":"application/octet-stream", ...}
oras blob fetch localhost:5000@digest --output blob.tar.gz --descriptor // `stdout` for printing progress status, and save the descriptor to the local file.
Fetched localhost:hello-world@digest
Save to file: blob.tar.gz
oras blob fetch localhost:5000@digest
Error message: Either --output or --descriptor must be provided
Option 4:
Use an optional --output flag: oras blob fetch localhost:5000@digest
No matter --output flag is used or not, always print readable blob contents, or print the descriptor if --descriptor is used.
No matter --output flag is used or not, if the blob content is not readable, print the warning messages to inform the user it is not readable.
oras blob fetch localhost:5000@digest --output blob.tar.gz
Warning: This blob is an unreadable binary file that can mess up your terminal. You can add the flag "--output" to save it locally.
Question: How could we determine whether it is readable? isatty? (Playing with terminals are complex)
@lizMSFT Can you add if blob path is '-', output to stdout to option1? So user can do cool things like one-line downloading and unzipping for a tarball blob as below:
oras fetch some.reg/repo@digest - | tar -xz -C unzipped
And one vote for both option1 and 2 since they are the same except the descriptor experience.
# INVALID: return error, either output or descriptor need to be provided, or provide both
oras blob fetch <name@digest>
# stdout: nothing, save blob content into file path. TODO: stdout progress status, e.g., use pv to view progress of commands
oras blob fetch <name@digest> --output <path>
# special case: stdout blob content.
# Note: --output - cannot be used with --descriptor at the same time
# Note: if `--output -` and `--pretty` are used at the same time, pretty flag will be ignored. (Blobs are intended to be binaries)
oras blob fetch <name> --output -
# stdout descriptor
oras blob fetch <name@digest> --descriptor
# stdout prettified descriptor
oras blob fetch <name@digest> --descriptor --pretty
# stdout descriptor, save blob content into file path
oras blob fetch <name@digest> --output <path> --descriptor
# stdout prettified descriptor, save blob content into file path
oras blob fetch <name@digest> --output <path> --descriptor --pretty
Activity
lizMSFT commentedon Aug 9, 2022
please assign this to me
lizMSFT commentedon Aug 18, 2022
Hi @shizhMSFT, should we enable ORAS_CACHE for this fetch blob workflow?
shizhMSFT commentedon Aug 18, 2022
Yes, should be also the same for
oras manifest fetchif applicable. /cc @qweeahlizMSFT commentedon Aug 19, 2022
crane: fetch a blob UX
doc: https://github.com/google/go-containerregistry/blob/main/cmd/crane/doc/crane_blob.md
code: https://github.com/google/go-containerregistry/blob/main/cmd/crane/cmd/blob.go#L26
Example:
crane blob zoeycr0707.azurecr.io/hello-world:linuxarmv5@sha256:b921b04d0447ddcd82a9220d887cd146f6ef39e20a938ee5e19a90fc3323e030 > blob.tar.gzWill save the blob output to the blob.tar.gz
crane blob zoeycr0707.azurecr.io/hello-world:linuxarmv5@sha256:b921b04d0447ddcd82a9220d887cd146f6ef39e20a938ee5e19a90fc3323e030Will print the output.
If the blob is a config, output will be like:
If the blob is a layer, the output is not readable since it is a binary file.
For oras fetch blob workflow, I am wondering how should we design the UX. Should we set the output (--output) as an optional flag or should we require users to provide output path since most of the blobs are not readable?
Do you have any suggestions? cc @FeynmanZhou @yizha1 @qweeah @shizhMSFT
qweeah commentedon Aug 22, 2022
Thanks @lizMSFT for driving this UX discussion. My thoughts are
Printing out a blob can be a valuable feature to user, e.g. when running
oras blob fetch mcr.microsoft.com/mcr/hello-world@sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587euser might want to only view the config content without saving it to a file.We should avoid printing out a unprintable blob. We can borrow the UX from curl like below:
FeynmanZhou commentedon Aug 22, 2022
I agree with @qweeah 's thoughts and I want to share two typical scenarios. To fetch a specific sha256 blob from a remote registry, there are two typical types of blob that users will request to:
a. JSON
b. Tar layer
shizhMSFT commentedon Aug 22, 2022
Blobs are intended to be binaries with garbled characters. Except config blobs, they are most likely to be non-printable. Since ORAS focuses more on artifacts where artifact manifest does not leverage configs, it does not make sense to print non-printable blobs by default.
Therefore, I’d like to always have an
--outputparameter to write the blob, and savestdoutfor printing progress status.Of course, we need a curl-like
--output -to output tostdout.yizha1 commentedon Aug 22, 2022
Here are my two cents:
--outputflag, so the user can store the blob somewhere in the file systemstdout, no matter output flag is used or not, so that the user can view it directly. It is convenient.stdoutfor non-readable Blob, but inform the user it is not readable, no matter--outputflag is used or not.lizMSFT commentedon Aug 23, 2022
Current options are:
Option 1:
oras blob fetch localhost:5000@digest blob.tar.gzstdoutfor printing progress status, e.g.,--descriptorflag:oras blob fetch localhost:hello-world@digest blob.tar.gz --descriptor.stdoutfor printing progress status, and save the descriptor toblob.tar.gzOption 2:
--outputflag:oras blob fetch localhost:5000@digest --output blob.tar.gzstdoutfor printing progress status, e.g.,--output -to output tostdoutno matter blob content is readable or not, e.g.,--descriptorflag:oras blob fetch localhost:hello-world@digest --output blob.tar.gz --descriptorstdoutfor printing progress status, and save the descriptor toblob.tar.gzoras blob fetch localhost:hello-world@digest --descriptor --output -stdoutfor printing the descriptorOption 3:
--outputflag:oras blob fetch localhost:5000@digest--outputor--descriptorMUST be provided, or provide both of them. Otherwise will return error, e.g.,Option 4:
--outputflag:oras blob fetch localhost:5000@digest--outputflag is used or not, always print readable blob contents, or print the descriptor if--descriptoris used.--outputflag is used or not, if the blob content is not readable, print the warning messages to inform the user it is not readable.isatty? (Playing with terminals are complex)cc @shizhMSFT @qweeah @FeynmanZhou @yizha1
yizha1 commentedon Aug 24, 2022
Option 1 and 3 are similar. The difference is option 3 allows printing descriptors to stdout. I vote for option 3.
qweeah commentedon Aug 25, 2022
@lizMSFT Can you add
if blob path is '-', output to stdoutto option1? So user can do cool things like one-line downloading and unzipping for a tarball blob as below:And one vote for both option1 and 2 since they are the same except the descriptor experience.
lizMSFT commentedon Aug 26, 2022
UX design (08/26/2022)