From 351249dce90d43cb8663e4f5bb822ef2588554a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 16 Aug 2024 16:36:33 +0200 Subject: [PATCH] list/tree: Print as dangling image name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- cli/command/image/tree.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/command/image/tree.go b/cli/command/image/tree.go index 010fadea21..fea7ceef3e 100644 --- a/cli/command/image/tree.go +++ b/cli/command/image/tree.go @@ -123,12 +123,14 @@ func printImageTree(dockerCLI command.Cli, images []topImage) error { topNameColor := aec.NewBuilder(aec.BlueF, aec.Underline, aec.Bold).ANSI normalColor := aec.NewBuilder(aec.DefaultF).ANSI greenColor := aec.NewBuilder(aec.GreenF).ANSI + untaggedColor := aec.NewBuilder(aec.Faint).ANSI if !out.IsTerminal() { headerColor = noColor{} topNameColor = noColor{} normalColor = noColor{} greenColor = noColor{} warningColor = noColor{} + untaggedColor = noColor{} } _, _ = fmt.Fprintln(out, warningColor.Apply("WARNING: This is an experimental feature. The output may change and shouldn't be depended on.")) @@ -216,7 +218,7 @@ func printImageTree(dockerCLI command.Cli, images []topImage) error { // Print images for _, img := range images { _, _ = fmt.Fprintln(out, "") - printNames(out, columns, img, topNameColor) + printNames(out, columns, img, topNameColor, untaggedColor) printDetails(out, columns, normalColor, img.Details) printChildren(out, columns, img, normalColor) } @@ -258,7 +260,11 @@ func printChildren(out *streams.Out, headers []imgColumn, img topImage, normalCo } } -func printNames(out *streams.Out, headers []imgColumn, img topImage, color aec.ANSI) { +func printNames(out *streams.Out, headers []imgColumn, img topImage, color, untaggedColor aec.ANSI) { + if len(img.Names) == 0 { + _, _ = fmt.Fprint(out, headers[0].Print(untaggedColor, "")) + } + for nameIdx, name := range img.Names { if nameIdx != 0 { _, _ = fmt.Fprintln(out, "")