Ver código fonte

API: ensure empty build cache is represented as empty JSON array

Ensure empty `BuildCache` field is represented as empty JSON array(`[]`)
instead of `null` to be consistent with `Images`, `Containers` etc.

Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
Roman Volosatovs 4 anos atrás
pai
commit
f2225933bb
2 arquivos alterados com 6 adições e 0 exclusões
  1. 5 0
      api/server/router/system/system_routes.go
  2. 1 0
      api/swagger.yaml

+ 5 - 0
api/server/router/system/system_routes.go

@@ -120,6 +120,11 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
 
 
 	du.BuilderSize = builderSize
 	du.BuilderSize = builderSize
 	du.BuildCache = buildCache
 	du.BuildCache = buildCache
+	if buildCache == nil {
+		// Ensure empty `BuildCache` field is represented as empty JSON array(`[]`)
+		// instead of `null` to be consistent with `Images`, `Containers` etc.
+		du.BuildCache = []*types.BuildCache{}
+	}
 
 
 	return httputils.WriteJSON(w, http.StatusOK, du)
 	return httputils.WriteJSON(w, http.StatusOK, du)
 }
 }

+ 1 - 0
api/swagger.yaml

@@ -8339,6 +8339,7 @@ paths:
                   UsageData:
                   UsageData:
                     Size: 10920104
                     Size: 10920104
                     RefCount: 2
                     RefCount: 2
+              BuildCache: []
         500:
         500:
           description: "server error"
           description: "server error"
           schema:
           schema: