Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cli/command/formatter/disk_usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

const (
defaultDiskUsageImageTableFormat = "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}\t{{.VirtualSize}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}"
defaultDiskUsageImageTableFormat = "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}\t{{.Size}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}"
defaultDiskUsageContainerTableFormat = "table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.Size}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}"
defaultDiskUsageVolumeTableFormat = "table {{.Name}}\t{{.Links}}\t{{.Size}}"
defaultDiskUsageBuildCacheTableFormat = "table {{.ID}}\t{{.CacheType}}\t{{.Size}}\t{{.CreatedSince}}\t{{.LastUsedSince}}\t{{.UsageCount}}\t{{.Shared}}"
Expand Down Expand Up @@ -296,10 +296,10 @@ func (c *diskUsageImagesContext) Reclaimable() string {

for _, i := range c.images {
if i.Containers != 0 {
if i.VirtualSize == -1 || i.SharedSize == -1 {
if i.Size == -1 || i.SharedSize == -1 {
continue
}
used += i.VirtualSize - i.SharedSize
used += i.Size - i.SharedSize
}
}

Expand Down
13 changes: 9 additions & 4 deletions cli/command/formatter/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func newImageContext() *imageContext {
"CreatedAt": CreatedAtHeader,
"Size": SizeHeader,
"Containers": containersHeader,
"VirtualSize": SizeHeader,
"VirtualSize": SizeHeader, // Deprecated: VirtualSize is deprecated, and equivalent to Size.
"SharedSize": sharedSizeHeader,
"UniqueSize": uniqueSizeHeader,
}
Expand Down Expand Up @@ -260,8 +260,13 @@ func (c *imageContext) Containers() string {
return fmt.Sprintf("%d", c.i.Containers)
}

// VirtualSize shows the virtual size of the image and all of its parent
// images. Starting with docker 1.10, images are self-contained, and
// the VirtualSize is identical to Size.
//
// Deprecated: VirtualSize is deprecated, and equivalent to [imageContext.Size].
func (c *imageContext) VirtualSize() string {
return units.HumanSize(float64(c.i.VirtualSize))
return units.HumanSize(float64(c.i.Size))
}

func (c *imageContext) SharedSize() string {
Expand All @@ -272,8 +277,8 @@ func (c *imageContext) SharedSize() string {
}

func (c *imageContext) UniqueSize() string {
if c.i.VirtualSize == -1 || c.i.SharedSize == -1 {
if c.i.Size == -1 || c.i.SharedSize == -1 {
return "N/A"
}
return units.HumanSize(float64(c.i.VirtualSize - c.i.SharedSize))
return units.HumanSize(float64(c.i.Size - c.i.SharedSize))
}
8 changes: 4 additions & 4 deletions cli/command/formatter/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestImageContext(t *testing.T) {
call: ctx.ID,
},
{
imageCtx: imageContext{i: types.ImageSummary{Size: 10, VirtualSize: 10}, trunc: true},
imageCtx: imageContext{i: types.ImageSummary{Size: 10}, trunc: true},
expValue: "10B",
call: ctx.Size,
},
Expand Down Expand Up @@ -70,17 +70,17 @@ func TestImageContext(t *testing.T) {
call: ctx.Containers,
},
{
imageCtx: imageContext{i: types.ImageSummary{VirtualSize: 10000}},
imageCtx: imageContext{i: types.ImageSummary{Size: 10000}},
expValue: "10kB",
call: ctx.VirtualSize,
call: ctx.VirtualSize, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
},
{
imageCtx: imageContext{i: types.ImageSummary{SharedSize: 10000}},
expValue: "10kB",
call: ctx.SharedSize,
},
{
imageCtx: imageContext{i: types.ImageSummary{SharedSize: 5000, VirtualSize: 20000}},
imageCtx: imageContext{i: types.ImageSummary{SharedSize: 5000, Size: 20000}},
expValue: "15kB",
call: ctx.UniqueSize,
},
Expand Down