-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
filters: add basic pattern matching for label keys i.e --filter label=<pattern>
#12295
Merged
openshift-merge-robot
merged 1 commit into
containers:main
from
flouthoc:filter-label-pattern
Nov 18, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
does it need to handle only
*
?Perhaps you could use
filepath.Match
?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.
Yes I think that would be much better. otherwise you might end up with more regex failures.
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.
I thought of it first but we want to match
label
keys wherefilepath.Match
does not works for cases like. Filepath is very restricted to matching valid path. However my idea was to match for patterns.This fails with
filepath.Match
and few more cases.fmt.Println(filepath.Match("/home/c*", "/home/catch/foo"))
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.
how does Docker do it?
If Docker doesn't do it, could we just use a regex here?
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.
I don't think docker does it. This was a new feature request. Afaik people mostly use
pipe
andgrep
with docker for that.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.
I tend to agree that a regex is better - it's definitely more complicated but attempting to treat labels as a path seems very fragile?
Besides, Podman does absolutely no standardization of label formats, so there's neither guarantee nor obligation for labels to include slashes as separators.
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.
@giuseppe I think
regex
likeregexp.MatchString("hello", key)
would match allkeys
starting withhello
so--filter label=
becomes hard to use. But I'll try it out.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.
My problem with regex is almost no human beings understand it and it has a lot more symbols.
People understand globing , well at least () a lot better then (.)
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.
Docker has a very small documentation but it only talks about
*
in examples https://docs.docker.com/engine/reference/commandline/images/#filtering . We could do aregex
but lot of tests would need to be readjusted.https://kliushnikov.medium.com/filtering-docker-images-5eb5aee358df
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.
Nvm found a fix also confirmed with @giuseppe I'll amend the PR.