1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

API: add shared-size parameter to image queries

The reasoning for this change is to be able to query image shared size without having to rely on the more heavyweight `/system/df` endpoint.

Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
This commit is contained in:
Roman Volosatovs 2021-06-28 17:30:53 +02:00
parent bf9c76f0a8
commit 2af9bd3b26
No known key found for this signature in database
GPG key ID: 216DD5F8CA6618A1
3 changed files with 17 additions and 2 deletions

View file

@ -236,9 +236,16 @@ func (s *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
}
}
var sharedSize bool
if versions.GreaterThanOrEqualTo(version, "1.42") {
// NOTE: Support for the "shared-size" parameter was added in API 1.42.
sharedSize = httputils.BoolValue(r, "shared-size")
}
images, err := s.backend.Images(ctx, types.ImageListOptions{
Filters: imageFilters,
All: httputils.BoolValue(r, "all"),
All: httputils.BoolValue(r, "all"),
Filters: imageFilters,
SharedSize: sharedSize,
})
if err != nil {
return err

View file

@ -7202,6 +7202,11 @@ paths:
- `reference`=(`<image-name>[:<tag>]`)
- `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`)
type: "string"
- name: "shared-size"
in: "query"
description: "Compute and show shared size as a `SharedSize` field on each image."
type: "boolean"
default: false
- name: "digests"
in: "query"
description: "Show digest information as a `RepoDigests` field on each image."

View file

@ -21,6 +21,9 @@ keywords: "API, Docker, rcli, REST, documentation"
was introduced in API 1.31 as part of an experimental feature, and no longer
used since API 1.40.
Use field `BuildCache` instead to track storage used by the builder component.
* `GET /images/json` now accepts query parameter `shared-size`. When set `true`,
images returned will include `SharedSize`, which provides the size on disk shared
with other images present on the system.
## v1.41 API changes