From f2225933bbdb62bd7e9b39796375911f361d188c Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Thu, 8 Jul 2021 13:12:13 +0200 Subject: [PATCH 1/2] 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 --- api/server/router/system/system_routes.go | 5 +++++ api/swagger.yaml | 1 + 2 files changed, 6 insertions(+) diff --git a/api/server/router/system/system_routes.go b/api/server/router/system/system_routes.go index 27063fc0ff..246cc67415 100644 --- a/api/server/router/system/system_routes.go +++ b/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.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) } diff --git a/api/swagger.yaml b/api/swagger.yaml index 40beae7a32..ddb8544bcc 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -8339,6 +8339,7 @@ paths: UsageData: Size: 10920104 RefCount: 2 + BuildCache: [] 500: description: "server error" schema: From 83e3dd68ca89bdee0c3f3cf40293d88e2992db4d Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Thu, 8 Jul 2021 13:15:46 +0200 Subject: [PATCH 2/2] swagger: add BuildCache example to `/system/df` Co-authored-by: Sebastiaan van Stijn Signed-off-by: Roman Volosatovs --- api/swagger.yaml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/api/swagger.yaml b/api/swagger.yaml index ddb8544bcc..0921cc1e2c 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -8339,7 +8339,29 @@ paths: UsageData: Size: 10920104 RefCount: 2 - BuildCache: [] + BuildCache: + - + ID: "hw53o5aio51xtltp5xjp8v7fx" + Parent: "" + Type: "regular" + Description: "pulled from docker.io/library/debian@sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0" + InUse: false + Shared: true + Size: 0 + CreatedAt: "2021-06-28T13:31:01.474619385Z" + LastUsedAt: "2021-07-07T22:02:32.738075951Z" + UsageCount: 26 + - + ID: "ndlpt0hhvkqcdfkputsk4cq9c" + Parent: "hw53o5aio51xtltp5xjp8v7fx" + Type: "regular" + Description: "mount / from exec /bin/sh -c echo 'Binary::apt::APT::Keep-Downloaded-Packages \"true\";' > /etc/apt/apt.conf.d/keep-cache" + InUse: false + Shared: true + Size: 51 + CreatedAt: "2021-06-28T13:31:03.002625487Z" + LastUsedAt: "2021-07-07T22:02:32.773909517Z" + UsageCount: 26 500: description: "server error" schema: