Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Filter query parameter to list images api #6878

Conversation

skorhone
Copy link

@skorhone skorhone commented Jul 7, 2020

Docker api version 1.24 uses a query parameter named Filter for filtering images by names. In more recent versions of api name filter is in filters query parameter with other filters

This patch adds a mapping that translates Filter query parameter to Filters={"reference": [""]}

Patch resolves issue: #6797

@openshift-ci-robot
Copy link
Collaborator

Hi @skorhone. Thanks for your PR.

I'm waiting for a containers member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 7, 2020
@skorhone skorhone force-pushed the fix/docker_v1_24_image_list_compatibility branch from ce18785 to 6c3f80a Compare July 7, 2020 08:57
@vrothberg
Copy link
Member

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 7, 2020
if len(query.Filters) > 0 {
for k, v := range query.Filters {
queryFilters := query.Filters
if len(query.Filter) > 0 { // Docker 1.24 compatibility
Copy link
Member

@vrothberg vrothberg Jul 7, 2020

Choose a reason for hiding this comment

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

Here, we need to make sure that we only accept this parameter for the docker-compat endpoints. There's a helper function to check if the request for libpod:

if !IsLibpodRequest(r) && en(query.Filter) > 0 { ...

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense. Added this check.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, @skorhone!

I'd love to have a test for the filter parameter in test/apiv2/10-images.at.

@skorhone
Copy link
Author

skorhone commented Jul 7, 2020

@vrothberg I'll have a look at those tests.

Also, it seems that currently name/reference filter is a bit too relaxed. It does seem to allow partial matches for names and tags. If it's much of an issue with name, but tag matching should be strict. Filter for image:v1 should not match with image:v10 like it currently does.

@skorhone skorhone force-pushed the fix/docker_v1_24_image_list_compatibility branch 2 times, most recently from 55dd925 to b2e6fc9 Compare July 7, 2020 09:56
Docker api version 1.24 uses a query parameter named Filter
for filtering images by names. In more recent versions of
api name filter is in filters query parameter with other
filters

This patch adds a mapping that translates Filter query
parameter to Filters={"reference": [""]}

Signed-off-by: Sami Korhonen <[email protected]>
@skorhone skorhone force-pushed the fix/docker_v1_24_image_list_compatibility branch from b2e6fc9 to 610118d Compare July 7, 2020 10:05
@skorhone
Copy link
Author

skorhone commented Jul 7, 2020

@vrothberg Now there's both positive and negative test cases

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot for contributing!

@rhatdan
Copy link
Member

rhatdan commented Jul 7, 2020

@baude @mheon @QiWang19 @ashley-cui PTAL

@mheon
Copy link
Member

mheon commented Jul 7, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 7, 2020
@rhatdan
Copy link
Member

rhatdan commented Jul 7, 2020

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan, skorhone

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2020
@openshift-merge-robot openshift-merge-robot merged commit 8014008 into containers:master Jul 7, 2020
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants