From 06666a5a23dcc004eb19af7f4b6028f481f74ab5 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Tue, 8 Nov 2016 22:40:46 -0500 Subject: [PATCH] use human readable units when listing secrets Signed-off-by: Evan Hazlett --- command/secret/ls.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/command/secret/ls.go b/command/secret/ls.go index 1befdad9d0..67fc1daff6 100644 --- a/command/secret/ls.go +++ b/command/secret/ls.go @@ -4,10 +4,12 @@ import ( "context" "fmt" "text/tabwriter" + "time" "github.com/docker/docker/api/types" "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" + "github.com/docker/go-units" "github.com/spf13/cobra" ) @@ -52,7 +54,11 @@ func runSecretList(dockerCli *command.DockerCli, opts listOptions) error { fmt.Fprintf(w, "\n") for _, s := range secrets { - fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", s.ID, s.Spec.Annotations.Name, s.Meta.CreatedAt, s.Meta.UpdatedAt, s.SecretSize) + created := units.HumanDuration(time.Now().UTC().Sub(s.Meta.CreatedAt)) + " ago" + updated := units.HumanDuration(time.Now().UTC().Sub(s.Meta.UpdatedAt)) + " ago" + size := units.HumanSizeWithPrecision(float64(s.SecretSize), 3) + + fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", s.ID, s.Spec.Annotations.Name, created, updated, size) } }