Show image download size as human-readable approximation

Signed-off-by: Han Verstraete <welteki@pm.me>
This commit is contained in:
Han Verstraete
2022-04-02 08:15:44 +00:00
committed by Alex Ellis
parent 4b132315c7
commit e09f37e5cb
3 changed files with 4 additions and 1 deletions

1
go.mod
View File

@ -13,6 +13,7 @@ require (
github.com/docker/distribution v2.8.0+incompatible
github.com/docker/docker v17.12.0-ce-rc1.0.20191113042239-ea84732a7725+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.3 // indirect
github.com/docker/go-units v0.4.0
github.com/gorilla/mux v1.8.0
github.com/morikuni/aec v1.0.0
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d

View File

@ -24,6 +24,7 @@ import (
"github.com/pkg/errors"
"github.com/containerd/containerd/namespaces"
units "github.com/docker/go-units"
"github.com/opencontainers/runtime-spec/specs-go"
)
@ -112,7 +113,7 @@ func (s *Supervisor) Start(svcs []Service) error {
}
images[svc.Name] = img
size, _ := img.Size(ctx)
fmt.Printf("Prepare done for: %s, %d bytes\n", svc.Image, size)
fmt.Printf("Prepare done for: %s, %s\n", svc.Image, units.HumanSize(float64(size)))
}
for _, svc := range svcs {

1
vendor/modules.txt generated vendored
View File

@ -151,6 +151,7 @@ github.com/docker/go-connections/nat
# github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c
github.com/docker/go-events
# github.com/docker/go-units v0.4.0
## explicit
github.com/docker/go-units
# github.com/gogo/googleapis v1.4.0
github.com/gogo/googleapis/google/rpc