@@ -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 , "" )
@@ -338,8 +344,8 @@ func (h imgColumn) PrintR(clr aec.ANSI, s string) string {
338344
339345type noColor struct {}
340346
341- func (a noColor ) With (ansi ... aec.ANSI ) aec.ANSI {
342- return aec . NewBuilder ( ansi ... ). ANSI
347+ func (a noColor ) With (_ ... aec.ANSI ) aec.ANSI {
348+ return a
343349}
344350
345351func (a noColor ) Apply (s string ) string {
0 commit comments