-
Notifications
You must be signed in to change notification settings - Fork 198
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
Fix image filters parsing #1800
Conversation
Podman PR containers/podman#21260 |
83d80bd
to
1dbde92
Compare
@rhatdan @mtrmac @vrothberg PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick skim of the PR, I didn’t now compare with Docker.
From a quick spot check, this is not nearly as simple: IOW something somewhere ( |
1dbde92
to
0c46974
Compare
@mtrmac by implicit OR, do you mean the pattern match being done for the |
I read that loop to mean that ( Also see the reference examples in https://docs.docker.com/engine/reference/commandline/images/ or https://docs.docker.com/config/filter/ . |
0125270
to
d7dd506
Compare
From what I see and understand from the docs, looks like only |
If you mean a special case for
Admittedly the further down that list we go, the larger and more invasive the rewrite becomes… but restructuring |
Hum, |
8525bd6
to
87fbf91
Compare
Fix the libpodFilters parsing to ensure that we get a list of filters in the form of key=value. This matches what the docker endpoint does for filter parsing as well. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
87fbf91
to
807655c
Compare
When multiple filters are given, only return objects that match all the filters given by the user. This matches Docker behavior. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
807655c
to
a677c90
Compare
@mtrmac I fixed up the filterReference function as we discussed and added tests - PTAL. |
For the positive case, the reference key does an OR operation. For the negative case, the reference key does an AND operation. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
a677c90
to
4d2e31b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Semantics LGTM. Aesthetically I’d prefer some further simplification but it’s not really blocking if we were in a time pressure — feel free to merge as is.
return false, err | ||
} | ||
if matches { | ||
unwantedMatched = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This can outright
return false
now; code below doesn’t need to worry aboutunwanted…Matches
and theunwantedMatched
variable can be dropped.
// If there are no wanted match filters, then return false for the image | ||
// that matched the unwanted value otherwise return true | ||
if len(wantedReferenceMatches) == 0 { | ||
return !unwantedMatched, nil | ||
} | ||
|
||
// Go through the wanted matches | ||
// If an image matches the wanted filter but it also matches the unwanted | ||
// filter, don't add it to the output | ||
for _, value := range wantedReferenceMatches { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Then it might be a tiny bit more readable to have
if len(wanted…) != 0 {
for … wanted {
if matches { return true }
}
return false // wanted a match, but nothing found
}
return true // all requirements satisfied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… on second thought, the “all requirements satisfied” comment might be misleading (it somewhat suggests that there isn’t an early return true
in there). So this might not be worth it.
@mtrmac can you please add the approve and lgtm labels |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mtrmac, umohnani8 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 |
Fix image filters parsing Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Fix the libpodFilters parsing to ensure that
we get a list of filters in the form of key=value.
This matches what the docker endpoint does for filter
parsing as well.
When multiple filters are given, only return objects
that match all the filters given by the user.
This matches Docker behavior.