From e09f37e5cbdd4286950083022fd7a3396c38d18d Mon Sep 17 00:00:00 2001 From: Han Verstraete Date: Sat, 2 Apr 2022 08:15:44 +0000 Subject: [PATCH] Show image download size as human-readable approximation Signed-off-by: Han Verstraete --- go.mod | 1 + pkg/supervisor.go | 3 ++- vendor/modules.txt | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index cbfad67..21a55c1 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/pkg/supervisor.go b/pkg/supervisor.go index c7008eb..323c879 100644 --- a/pkg/supervisor.go +++ b/pkg/supervisor.go @@ -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 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 8122fa1..3224b00 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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