Skip to content

Commit

Permalink
list/tree: Print <untagged> as dangling image name
Browse files Browse the repository at this point in the history
Signed-off-by: Paweł Gronowski <[email protected]>
(cherry picked from commit 351249d)
Signed-off-by: Paweł Gronowski <[email protected]>
  • Loading branch information
vvoland committed Aug 16, 2024
1 parent 7196200 commit 7902b52
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cli/command/image/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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, "<untagged>"))
}

for nameIdx, name := range img.Names {
if nameIdx != 0 {
_, _ = fmt.Fprintln(out, "")
Expand Down

0 comments on commit 7902b52

Please sign in to comment.