Skip to content

api/image/list: Add container-count parameter#47501

Closed
vvoland wants to merge 1 commit intomoby:masterfrom
vvoland:image-list-containers
Closed

api/image/list: Add container-count parameter#47501
vvoland wants to merge 1 commit intomoby:masterfrom
vvoland:image-list-containers

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Mar 5, 2024

This parameter was already supported for some time in the backend (for purposes related to docker system prune).
It was also already present in the imagetypes.ListOptions but was never actually handled by the client.

This makes the client respect the ContainerCount and set the form field when sending the request.

- How to verify it

- Description for the changelog

`GET /images/json` now supports the `container-count` parameter which makes the response fill the `Containers` field with a count of containers using the image.  

- A picture of a cute animal (not mandatory but encouraged)

image

@vvoland vvoland added area/api API kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. impact/api impact/changelog area/images Image Distribution labels Mar 5, 2024
@vvoland vvoland added this to the 26.0.0 milestone Mar 5, 2024
@vvoland vvoland self-assigned this Mar 5, 2024
@thaJeztah
Copy link
Member

This looks to be similar to #43350 - do we have a use-case for this, or should we consider going the other direction (make sure we properly define types for each purpose). ISTR some of the usage types were just reusing existing types because someone was lazy to define separate ones 😞

@vvoland
Copy link
Contributor Author

vvoland commented Mar 5, 2024

We don't have an usage yet, I was mostly just fiddling around the multi-platform image list, and wanted to use the containers count as an indicator whether the image is used or not, but noticed that setting this field client-side doesn't actually do anything 🙈

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to have a closer look before we commit to this; leaving a quick "request changes"

@vvoland vvoland modified the milestones: 26.0.0, 27.0.0 Mar 13, 2024
@vvoland vvoland modified the milestones: 27.0.0, v-future Apr 5, 2024
}

var containerCount bool
if versions.GreaterThanOrEqualTo(version, "1.45") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjust API version

@vvoland vvoland modified the milestones: v-future, 28.0.0 Jul 26, 2024
@vvoland vvoland requested a review from thaJeztah July 26, 2024 09:25
@vvoland vvoland force-pushed the image-list-containers branch 2 times, most recently from c86efff to 793df46 Compare July 26, 2024 10:44
Copy link
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This parameter was already supported for some time in the backend (for
purposes related to `docker system prune`).
It was also already present in the `imagetypes.ListOptions` but was
never actually handled by the client.

This commits makes the client respect the `ContainerCount` and set the
form field when sending the request.

Signed-off-by: Paweł Gronowski <[email protected]>
@vvoland
Copy link
Contributor Author

vvoland commented Aug 16, 2024

Opened a related PR: #48345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API area/images Image Distribution impact/api impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants