mirror of https://github.com/docker/cli.git
Merge 54a4ab135f
into a5fb752ecf
This commit is contained in:
commit
0f0f4b7a98
|
@ -3,6 +3,7 @@ package image
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
@ -25,6 +26,9 @@ type treeOptions struct {
|
||||||
type treeView struct {
|
type treeView struct {
|
||||||
images []topImage
|
images []topImage
|
||||||
|
|
||||||
|
// showUsed indicates whether the "Used" column should be shown.
|
||||||
|
showUsed bool
|
||||||
|
|
||||||
// imageSpacing indicates whether there should be extra spacing between images.
|
// imageSpacing indicates whether there should be extra spacing between images.
|
||||||
imageSpacing bool
|
imageSpacing bool
|
||||||
}
|
}
|
||||||
|
@ -71,6 +75,9 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error
|
||||||
if sub.Details.Used {
|
if sub.Details.Used {
|
||||||
// Mark top-level parent image as used if any of its subimages are used.
|
// Mark top-level parent image as used if any of its subimages are used.
|
||||||
details.Used = true
|
details.Used = true
|
||||||
|
|
||||||
|
// Show the Used column only if there will be at least one non-zero value.
|
||||||
|
view.showUsed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
totalContent += im.Size.Content
|
totalContent += im.Size.Content
|
||||||
|
@ -192,6 +199,12 @@ func printImageTree(dockerCLI command.Cli, view treeView) error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !view.showUsed {
|
||||||
|
columns = slices.DeleteFunc(columns, func(c imgColumn) bool {
|
||||||
|
return c.Title == "Used"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
nameWidth := int(width)
|
nameWidth := int(width)
|
||||||
for idx, h := range columns {
|
for idx, h := range columns {
|
||||||
if h.Width == 0 {
|
if h.Width == 0 {
|
||||||
|
|
Loading…
Reference in New Issue