From a418c68e38b643fb329c66a7c0e52c21354056e2 Mon Sep 17 00:00:00 2001 From: Nate <37554478+servusdei2018@users.noreply.github.com> Date: Sun, 5 May 2024 15:54:50 -0400 Subject: [PATCH] formatters(image): prevent image size from displaying scientific notation --- cli/command/formatter/image.go | 2 +- cli/command/formatter/image_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/command/formatter/image.go b/cli/command/formatter/image.go index d16f42b5ba..5c569bdda7 100644 --- a/cli/command/formatter/image.go +++ b/cli/command/formatter/image.go @@ -248,7 +248,7 @@ func (c *imageContext) CreatedAt() string { } func (c *imageContext) Size() string { - return units.HumanSizeWithPrecision(float64(c.i.Size), 3) + return units.HumanSize(float64(c.i.Size)) } func (c *imageContext) Containers() string { diff --git a/cli/command/formatter/image_test.go b/cli/command/formatter/image_test.go index fcdf727c52..a6477f87c0 100644 --- a/cli/command/formatter/image_test.go +++ b/cli/command/formatter/image_test.go @@ -40,6 +40,11 @@ func TestImageContext(t *testing.T) { expValue: "10B", call: ctx.Size, }, + { + imageCtx: imageContext{i: types.ImageSummary{Size: 999900000}, trunc: true}, + expValue: "999.9MB", + call: ctx.Size, + }, { imageCtx: imageContext{i: image.Summary{Created: unix}, trunc: true}, expValue: time.Unix(unix, 0).String(), call: ctx.CreatedAt,