docker / app

Make your Docker Compose applications reusable, and share them on Docker Hub
Apache License 2.0
1.57k stars 177 forks source link

Rework docker app image ls and add the --digests flag #709

Closed zappy-shu closed 4 years ago

zappy-shu commented 4 years ago

- WIP Need to get an e2e or unit test that covers the digest.

- What I did

Reworked the image ls output to better match the docker image ls command. The output now has separate columns for REPOSITORY and TAG as well as an APP IMAGE ID column.

Added the --digests flag to image ls. This makes the image ls command print the image digests (if present) along with the other columns.

- How I did it

Made the columns list for image ls dynamic depending on what options are sent. The digest is retrieved by attempted to cast to a Digested type (i.e. the image has been stored by digest rather than by tag or ID). If not then just prints <none>.

- How to verify it

Pull an image from hub by digest and then run app image ls --digest. The image in question should show the digest prefixed by the algorithm type. E.g.

REPOSITORY   TAG    DIGEST          APP IMAGE ID APP NAME
<repository> <none> sha256@<digest> <id>         <name>

- Description for the changelog

Added the --digests flag to the app image ls command. When present, the command will print the image's digest or <none> if the image does not have a digest, along with other image details.

- A picture of a cute animal (not mandatory but encouraged)

pp

codecov[bot] commented 4 years ago

Codecov Report

Merging #709 into master will increase coverage by 0.1%. The diff coverage is 86.36%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #709     +/-   ##
========================================
+ Coverage    71.4%   71.5%   +0.1%     
========================================
  Files          59      59             
  Lines        3175    3201     +26     
========================================
+ Hits         2267    2289     +22     
- Misses        602     604      +2     
- Partials      306     308      +2
Impacted Files Coverage Δ
internal/commands/image/list.go 83.67% <86.36%> (+0.34%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9042ab2...24ced43. Read the comment docs.

chris-crone commented 4 years ago

Is the spacing between the columns the same as for container images? From the following, It looks to me like app has less spaces which makes it tricky to read.

➜  app git:(add-digest-flag-to-ls) docker app image ls
REPOSITORY       TAG  APP IMAGE ID APP NAME
ccrone/cnab-demo yves 6cca8f6428a9 coins
ccrone/cnab-demo yves 6cca8f6428a9 coins
➜  app git:(add-digest-flag-to-ls) docker images
REPOSITORY             TAG                           IMAGE ID            CREATED             SIZE
docker/cnab-app-base   v0.9.0-zeta1-66-g24ced43b0d   f5d2426e6a7f        2 minutes ago       47.7MB
ccrone/cnab-demo       <none>                        51a16e185d83        59 minutes ago      47.2MB
ccrone/cnab-demo       <none>                        7cc9617f5c36        About an hour ago   218MB
ccrone/cnab-demo       <none>                        de25a81a5a0b        2 weeks ago         98.2MB
zappy-shu commented 4 years ago

@chris-crone

I haven't touched the spacing as part of this PR but the tabwriter for the CLI does have different settings to the one used here:

cli := tabwriter.NewWriter(c.Output, 20, 1, 3, ' ', 0)
app := tabwriter.NewWriter(dockerCli.Out(), 0, 0, 1, ' ', 0)

Do we want to update the app tabwriter so the spacing match the CLI? Note that the CLI uses a generic formatter so we will probably need to change it in multiple places to completely match. Probably best do the others as part of a separate PR though

chris-crone commented 4 years ago

Do we want to update the app tabwriter so the spacing match the CLI?

Yes. That will make the feel the same.

Probably best do the others as part of a separate PR though

👍 Please just create a ticket to track