api/types/system: add type specific usage fields to DiskUsage

This change adds type specific fields to `GET /system/df` endpoint with high level information of disk usage. This change also introduces `verbose` query to the endpoint so that detailed information is by default excluded unless queried to reduce memory consumption. The previous top level `DiskUsage` fields (`Images`, `Containers`, `Volumes` and `BuildCache`) are now deprecated and kept for backwards compatibility.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
Austin Vazquez
2025-10-20 15:11:53 -05:00
parent bb27db85fb
commit a69abdd90d
27 changed files with 1633 additions and 437 deletions

View File

@@ -29,6 +29,17 @@ func assertRequest(req *http.Request, expMethod string, expectedPath string) err
return nil
}
func assertRequestWithQuery(req *http.Request, expMethod string, expectedPath string, expectedQuery string) error {
if err := assertRequest(req, expMethod, expectedPath); err != nil {
return err
}
q := req.URL.Query().Encode()
if q != expectedQuery {
return fmt.Errorf("expected query '%s', got '%s'", expectedQuery, q)
}
return nil
}
// ensureBody makes sure the response has a Body, using [http.NoBody] if
// none is present, and returns it as a testRoundTripper.
func ensureBody(f func(req *http.Request) (*http.Response, error)) testRoundTripper {