godarch / darch

A tool for building and booting stateless and immutable images, bare metal.
https://godarch.com/
MIT License
832 stars 32 forks source link

Printing cleaner images list #34

Closed arnarg closed 5 years ago

arnarg commented 5 years ago

fixes #10

This produces the following output:

>> sudo darch images list
REPOSITORY      TAG     CREATED     SIZE
godarch/arch    latest  2019-02-14  153.1 MiB
godarch/ubuntu  latest  2019-02-16  359.6 MiB
>> sudo darch images list -q
godarch/arch:latest
godarch/ubuntu:latest

If we want to also print the image id (digest) and size we would need to one of the following (that I can think of).

  1. Add those fields to the Image struct. Then in session.GetImages() we would need to call containerd.Image.Size() to calculate the size of each image. This would be unnecessarily expensive if you're not printing the table.
  2. In the for loop printing the table call session.client.ImageService().Get() to get the original containerd.Image object for each image and then calculate the size.
  3. Save the original containerd.Image in the Image struct.

What do you think?

pauldotknopf commented 5 years ago

I like option 2.

arnarg commented 5 years ago

I added the Size field. It depends on github.com/containerd/containerd/pkg/progress to convert the size from int64 to string but it's missing, is it ok to add? I also tried with the Digest field and it looked weird, maybe it can be formatted better or skipped altogether?

REPOSITORY      TAG     DIGEST                                                                   CREATED     SIZE
godarch/arch    latest  sha256:b15f7a112a30b04dc32ecaa56e00f0a5ac3b7a38978d80fe4b80ff97353bce5d  2019-02-14  153.1 MiB
godarch/ubuntu  latest  sha256:f5e7dd5e396a8a921a6452697deb3f0f4f572f63079da56a5383620d0dea7b24  2019-02-16  359.6 MiB
pauldotknopf commented 5 years ago

Run the following to fix the build error:

make ci_deps
make vendor
arnarg commented 5 years ago

I did that but github.com/containerd/containerd/pkg/progress has a dependency on github.com/docker/go-units and make vendor doesn't seem to be pulling that in.

pauldotknopf commented 5 years ago

Ah, then you'll want to add "github.com/docker/go-units" to the vendor.conf, and make sure it uses the same exact version the containerd is referencing.

pauldotknopf commented 5 years ago

https://github.com/containerd/containerd/blob/c4446665cb9c30056f4998ed953e6d4ff22c7c39/vendor.conf#L11

github.com/docker/go-units v0.3.1