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