Skip to content

Commit 351249d

Browse files
committed
list/tree: Print <untagged> as dangling image name
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
1 parent 6979ab0 commit 351249d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

cli/command/image/tree.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@ func printImageTree(dockerCLI command.Cli, images []topImage) error {
123123
topNameColor := aec.NewBuilder(aec.BlueF, aec.Underline, aec.Bold).ANSI
124124
normalColor := aec.NewBuilder(aec.DefaultF).ANSI
125125
greenColor := aec.NewBuilder(aec.GreenF).ANSI
126+
untaggedColor := aec.NewBuilder(aec.Faint).ANSI
126127
if !out.IsTerminal() {
127128
headerColor = noColor{}
128129
topNameColor = noColor{}
129130
normalColor = noColor{}
130131
greenColor = noColor{}
131132
warningColor = noColor{}
133+
untaggedColor = noColor{}
132134
}
133135

134136
_, _ = 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 {
216218
// Print images
217219
for _, img := range images {
218220
_, _ = fmt.Fprintln(out, "")
219-
printNames(out, columns, img, topNameColor)
221+
printNames(out, columns, img, topNameColor, untaggedColor)
220222
printDetails(out, columns, normalColor, img.Details)
221223
printChildren(out, columns, img, normalColor)
222224
}
@@ -258,7 +260,11 @@ func printChildren(out *streams.Out, headers []imgColumn, img topImage, normalCo
258260
}
259261
}
260262

261-
func printNames(out *streams.Out, headers []imgColumn, img topImage, color aec.ANSI) {
263+
func printNames(out *streams.Out, headers []imgColumn, img topImage, color, untaggedColor aec.ANSI) {
264+
if len(img.Names) == 0 {
265+
_, _ = fmt.Fprint(out, headers[0].Print(untaggedColor, "<untagged>"))
266+
}
267+
262268
for nameIdx, name := range img.Names {
263269
if nameIdx != 0 {
264270
_, _ = fmt.Fprintln(out, "")

0 commit comments

Comments
 (0)