summaryrefslogtreecommitdiff
path: root/api/server
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2023-04-17 13:21:59 +0200
committerSebastiaan van Stijn <github@gone.nl>2023-05-06 16:35:00 +0200
commit913b0f51cab18a56247a950f5f1e75ca79b63039 (patch)
treee9ce8c51d9d7a5541ed79aa6497ad2fcc7c7ca25 /api/server
parent88f4bf4ae4bace73608b73df9fb974081d2bed1a (diff)
downloaddocker-913b0f51cab18a56247a950f5f1e75ca79b63039.tar.gz
API: omit deprecated VirtualSize field for API v1.44 and up
This field is deprecated since 1261fe69a3586bb102182aa885197822419c768c, and will now be omitted on API v1.44 and up for the `GET /images/json`, `GET /images/{id}/json`, and `GET /system/df` endpoints. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'api/server')
-rw-r--r--api/server/router/image/image_routes.go9
-rw-r--r--api/server/router/system/system_routes.go5
2 files changed, 13 insertions, 1 deletions
diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go
index 1500f0e876..9d5418369b 100644
--- a/api/server/router/image/image_routes.go
+++ b/api/server/router/image/image_routes.go
@@ -263,6 +263,10 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
return err
}
+ version := httputils.VersionFromContext(ctx)
+ if versions.LessThan(version, "1.44") {
+ imageInspect.VirtualSize = imageInspect.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
+ }
return httputils.WriteJSON(w, http.StatusOK, imageInspect)
}
@@ -299,7 +303,6 @@ func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, er
Os: img.OperatingSystem(),
OsVersion: img.OSVersion,
Size: img.Details.Size,
- VirtualSize: img.Details.Size, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
GraphDriver: types.GraphDriverData{
Name: img.Details.Driver,
Data: img.Details.Metadata,
@@ -357,6 +360,7 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
}
useNone := versions.LessThan(version, "1.43")
+ withVirtualSize := versions.LessThan(version, "1.44")
for _, img := range images {
if useNone {
if len(img.RepoTags) == 0 && len(img.RepoDigests) == 0 {
@@ -371,6 +375,9 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
img.RepoDigests = []string{}
}
}
+ if withVirtualSize {
+ img.VirtualSize = img.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
+ }
}
return httputils.WriteJSON(w, http.StatusOK, images)
diff --git a/api/server/router/system/system_routes.go b/api/server/router/system/system_routes.go
index e918215fdb..6bfcd673f1 100644
--- a/api/server/router/system/system_routes.go
+++ b/api/server/router/system/system_routes.go
@@ -185,6 +185,11 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
b.Parent = "" //nolint:staticcheck // ignore SA1019 (Parent field is deprecated)
}
}
+ if versions.LessThan(version, "1.44") {
+ for _, b := range systemDiskUsage.Images {
+ b.VirtualSize = b.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
+ }
+ }
du := types.DiskUsage{
BuildCache: buildCache,