changed 2 years ago
Published Linked with GitHub

CLI Output Guidelines for ORAS CLI

The goal is to outline a set of guidelines to improve the console output of the ORAS CLI. This uses the copy command cp as an example to call out issues.

Refer CLI Output Proposal for COPY with referrers

Framework :

  1. Default Output

    1. Useful
    2. Concise
    3. Human readable
  2. Verbose Logging Ouput

    1. This is user viewable feature
    2. can be used by the user for troubleshooting the scenarios they would like to achieve.
    3. Should focus on human readable output
  3. Debug Output

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
    debug is ORAS developers only

    1. Useful for application builders that are looking to fix a bug in ORAS
    2. Consider showing internal CLI/API and variable states and possibly consider timing.
    3. Ensure that there is a warning that clients should not take dependency of format or fields of DEBUG outputs.
    4. Consider debug as exposed through environment variables :::note
  • This focuses on copycp but the general recommendation might be applicable for other commands.
  • Recommend each command have a proposal doc that is reviewed by maintainers or stake holders.

Verbose logging experience

Following curl and other tools as an example here -

  • -v is the only option that a CLI users should be using. By default verbose is output is visibible to standard out

  • Can be suppressed by redirection

  • Stdout will only include the actual outputs and not the verbose logs

  • Both stdout and vebose logs can be redirected as follow

Include warning in verbose and debug logs

Example of client showing that these are not stable.

Looking at ORAS cp

$ oras cp docker.io/library/hello-world:latest --platform linux/amd64 --to-oci-layout .
Copied [registry] docker.io/library/hello-world:latest => [oci-layout] .
Digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4

Observations :

  • The information that is useful here is just the digest.
  • This is probably too concise.

Recommendataion:

  • Docker CLI outputs the layers and possibly keeping in line with that is my take.
  • Add info from verbose logs in the default output.

Current verbose output

$ oras cp docker.io/library/hello-world:latest --platform linux/amd64 \
    --to-oci-layout . \
    --verbose
Copying 2db29710123e application/vnd.docker.image.rootfs.diff.tar.gzip
Copying feb5d9fea6a5 application/vnd.docker.container.image.v1+json
Copied  2db29710123e application/vnd.docker.image.rootfs.diff.tar.gzip
Copied  feb5d9fea6a5 application/vnd.docker.container.image.v1+json
Copying f54a58bc1aac application/vnd.docker.distribution.manifest.v2+json
Copied  f54a58bc1aac application/vnd.docker.distribution.manifest.v2+json
Copied [registry] docker.io/library/hello-world:latest => [oci-layout] .
Digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4

Observations:

  • This is more inline with what I consider as default output.
  • Usable and indicates the number of layers etc.

Expected output with verbose

Proposal

  • --debug is not requred anymore
  • --detailed is not needed here or in other commands if present
  • Reduce the volume by removing redundant words like request/response in every log line
  • Remove quotations to align with regular outputs.
$ oras cp docker.io/library/hello-world:latest \
    --platform linux/amd64 --to-oci-layout . \
    --verbose
Request #0
> URI:  https://registry-1.docker.io/v2/library/hello-world/manifests/latest
> Method: GET
> Headers:
   Accept: application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, application/vnd.oci.artifact.manifest.v1+json
   User-Agent: oras/1.0.0
Response #0
< Status: 401 Unauthorized
< Headers:
   Date: Tue, 04 Apr 2023 14:54:11 GMT
   Content-Length: 162
   Content-Type: application/json
   Docker-Distribution-Api-Version: registry/2.0
   Www-Authenticate: Bearer realm=\https://auth.docker.io/token\,service=\registry.docker.io\,scope=\repository:library/hello-world:pull\
   Strict-Transport-Security: max-age=31536000
   Docker-Ratelimit-Source: 4.194.235.164

...

Support redirection of verbose output to stderr

Consider the following example -v is shows the output the user but it can be redirect to 2>/dev/null

❯ curl -v https://bing.com
*   Trying 204.79.197.200:443...
* Connected to bing.com (204.79.197.200) port 443 (#0)
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
❯ curl -v https://bing.com 2>/dev/null
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://www.bing.com:443/?toWww=1&amp;redig=B44C4C1386F745A5831C7DBE82203C2C">here</a>.</h2>
</body></html>

Handling concurrency in verbose outputs

There are few options we can consdier for this.

  1. Do nothing
  2. Suffix > or < with an operation id like >[1]
Select a repo