mirror of https://github.com/docker/cli.git
cli/tree: Add `Content size` column
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit ea8aafcd9e
)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
99b647cfca
commit
ba43ae0bd2
|
@ -39,12 +39,14 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error
|
|||
Used: img.Containers > 0,
|
||||
}
|
||||
|
||||
var totalContent int64
|
||||
children := make([]subImage, 0, len(img.Manifests))
|
||||
for _, im := range img.Manifests {
|
||||
if im.Kind != imagetypes.ManifestKindImage {
|
||||
continue
|
||||
}
|
||||
|
||||
im := im
|
||||
sub := subImage{
|
||||
Platform: platforms.Format(im.ImageData.Platform),
|
||||
Available: im.Available,
|
||||
|
@ -52,12 +54,15 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error
|
|||
ID: im.ID,
|
||||
DiskUsage: units.HumanSizeWithPrecision(float64(im.Size.Total), 3),
|
||||
Used: len(im.ImageData.Containers) > 0,
|
||||
ContentSize: units.HumanSizeWithPrecision(float64(im.Size.Content), 3),
|
||||
},
|
||||
}
|
||||
|
||||
totalContent += im.Size.Content
|
||||
children = append(children, sub)
|
||||
}
|
||||
|
||||
details.ContentSize = units.HumanSizeWithPrecision(float64(totalContent), 3)
|
||||
view = append(view, topImage{
|
||||
Names: img.RepoTags,
|
||||
Details: details,
|
||||
|
@ -72,6 +77,7 @@ type imageDetails struct {
|
|||
ID string
|
||||
DiskUsage string
|
||||
Used bool
|
||||
ContentSize string
|
||||
}
|
||||
|
||||
type topImage struct {
|
||||
|
@ -125,6 +131,13 @@ func printImageTree(dockerCLI command.Cli, images []topImage) error {
|
|||
return d.DiskUsage
|
||||
},
|
||||
},
|
||||
{
|
||||
Title: "Content size",
|
||||
Width: 12,
|
||||
DetailsValue: func(d *imageDetails) string {
|
||||
return d.ContentSize
|
||||
},
|
||||
},
|
||||
{
|
||||
Title: "Used",
|
||||
Width: 4,
|
||||
|
|
Loading…
Reference in New Issue