mirror of https://github.com/docker/cli.git
remove uses of deprecated VirtualSize field
The VirtualSize field is deprecated and the upcoming API version v1.44 will no longer propagate the field. See:1261fe69a3
, Given that in docker 1.10 and up (API v1.22), the VirtualSize and Size fields contain the same value, and the "df" endpoint was not supported until API v1.25, we can "safely" use Size instead; see: -4ae7176ffb
-4352da7803
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
59b07b7253
commit
f02301ab5d
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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}}"
|
defaultDiskUsageContainerTableFormat = "table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.Size}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}"
|
||||||
defaultDiskUsageVolumeTableFormat = "table {{.Name}}\t{{.Links}}\t{{.Size}}"
|
defaultDiskUsageVolumeTableFormat = "table {{.Name}}\t{{.Links}}\t{{.Size}}"
|
||||||
defaultDiskUsageBuildCacheTableFormat = "table {{.ID}}\t{{.CacheType}}\t{{.Size}}\t{{.CreatedSince}}\t{{.LastUsedSince}}\t{{.UsageCount}}\t{{.Shared}}"
|
defaultDiskUsageBuildCacheTableFormat = "table {{.ID}}\t{{.CacheType}}\t{{.Size}}\t{{.CreatedSince}}\t{{.LastUsedSince}}\t{{.UsageCount}}\t{{.Shared}}"
|
||||||
|
@ -296,10 +296,10 @@ func (c *diskUsageImagesContext) Reclaimable() string {
|
||||||
|
|
||||||
for _, i := range c.images {
|
for _, i := range c.images {
|
||||||
if i.Containers != 0 {
|
if i.Containers != 0 {
|
||||||
if i.VirtualSize == -1 || i.SharedSize == -1 {
|
if i.Size == -1 || i.SharedSize == -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
used += i.VirtualSize - i.SharedSize
|
used += i.Size - i.SharedSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ func newImageContext() *imageContext {
|
||||||
"CreatedAt": CreatedAtHeader,
|
"CreatedAt": CreatedAtHeader,
|
||||||
"Size": SizeHeader,
|
"Size": SizeHeader,
|
||||||
"Containers": containersHeader,
|
"Containers": containersHeader,
|
||||||
"VirtualSize": SizeHeader,
|
"VirtualSize": SizeHeader, // Deprecated: VirtualSize is deprecated, and equivalent to Size.
|
||||||
"SharedSize": sharedSizeHeader,
|
"SharedSize": sharedSizeHeader,
|
||||||
"UniqueSize": uniqueSizeHeader,
|
"UniqueSize": uniqueSizeHeader,
|
||||||
}
|
}
|
||||||
|
@ -260,8 +260,13 @@ func (c *imageContext) Containers() string {
|
||||||
return fmt.Sprintf("%d", c.i.Containers)
|
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 {
|
func (c *imageContext) VirtualSize() string {
|
||||||
return units.HumanSize(float64(c.i.VirtualSize))
|
return units.HumanSize(float64(c.i.Size))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *imageContext) SharedSize() string {
|
func (c *imageContext) SharedSize() string {
|
||||||
|
@ -272,8 +277,8 @@ func (c *imageContext) SharedSize() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *imageContext) UniqueSize() 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 "N/A"
|
||||||
}
|
}
|
||||||
return units.HumanSize(float64(c.i.VirtualSize - c.i.SharedSize))
|
return units.HumanSize(float64(c.i.Size - c.i.SharedSize))
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ func TestImageContext(t *testing.T) {
|
||||||
call: ctx.ID,
|
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",
|
expValue: "10B",
|
||||||
call: ctx.Size,
|
call: ctx.Size,
|
||||||
},
|
},
|
||||||
|
@ -70,9 +70,9 @@ func TestImageContext(t *testing.T) {
|
||||||
call: ctx.Containers,
|
call: ctx.Containers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
imageCtx: imageContext{i: types.ImageSummary{VirtualSize: 10000}},
|
imageCtx: imageContext{i: types.ImageSummary{Size: 10000}},
|
||||||
expValue: "10kB",
|
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}},
|
imageCtx: imageContext{i: types.ImageSummary{SharedSize: 10000}},
|
||||||
|
@ -80,7 +80,7 @@ func TestImageContext(t *testing.T) {
|
||||||
call: ctx.SharedSize,
|
call: ctx.SharedSize,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
imageCtx: imageContext{i: types.ImageSummary{SharedSize: 5000, VirtualSize: 20000}},
|
imageCtx: imageContext{i: types.ImageSummary{SharedSize: 5000, Size: 20000}},
|
||||||
expValue: "15kB",
|
expValue: "15kB",
|
||||||
call: ctx.UniqueSize,
|
call: ctx.UniqueSize,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue