API: discard /system/df type parameter pre-1.42

The parameter is introduced in API version 1.42

Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
This commit is contained in:
Roman Volosatovs 2021-08-06 15:52:37 +02:00
parent 5e498e20f7
commit 0fdd23b7fe
No known key found for this signature in database
GPG key ID: 216DD5F8CA6618A1

View file

@ -94,8 +94,11 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
return err
}
version := httputils.VersionFromContext(ctx)
var getContainers, getImages, getVolumes, getBuildCache bool
if typeStrs, ok := r.Form["type"]; !ok {
typeStrs, ok := r.Form["type"]
if versions.LessThan(version, "1.42") || !ok {
getContainers, getImages, getVolumes, getBuildCache = true, true, true, true
} else {
for _, typ := range typeStrs {
@ -151,7 +154,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
}
var builderSize int64
if versions.LessThan(httputils.VersionFromContext(ctx), "1.42") {
if versions.LessThan(version, "1.42") {
for _, b := range buildCache {
builderSize += b.Size
}