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

filters: better handling of id= #18798

Merged
merged 1 commit into from
Jun 7, 2023

Conversation

edsantiago
Copy link
Member

For filter=id=XXX:

if XXX is only hex characters, treat it as a PREFIX
otherwise, treat it as a REGEX

Fixes: #18471

Signed-off-by: Ed Santiago [email protected]

Filtering by 'id=xxx' will now treat xxx as a CID prefix, not a regular expression

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 5, 2023
@edsantiago edsantiago force-pushed the fix_filters branch 3 times, most recently from 365ed47 to 22dabb9 Compare June 6, 2023 01:43
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago, zhangguanzhang

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:
  • OWNERS [edsantiago,zhangguanzhang]

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

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

I think you also have to fix this for pod filters.
I will fix the network filters in c/common when this is merged.

Also considering that there was a fair bit of confusion about the docs I think you should clarify the behaviour there.

@@ -18,9 +19,20 @@ import (
func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpod.Runtime) (func(container *libpod.Container) bool, error) {
switch filter {
case "id":
// we only have to match one ID
hexRegex := regexp.MustCompile("[^0-9a-fA-F]")
Copy link
Member

Choose a reason for hiding this comment

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

this should be a global variable and use the "github.com/containers/storage/pkg/regexp" package instead.

@TomSweeneyRedHat
Copy link
Member

Other thatn @Luap99 's comments, LGTM

@edsantiago edsantiago force-pushed the fix_filters branch 2 times, most recently from 44aca7c to 3bc098a Compare June 7, 2023 02:21
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/domain/filters/pods.go Outdated Show resolved Hide resolved
For filter=id=XXX (containers, pods) and =ctr-ids=XXX (pods):

  if XXX is only hex characters, treat it as a PREFIX
  otherwise, treat it as a REGEX

Add tests. Update documentation. And fix an incorrect help message.

Fixes: containers#18471

Signed-off-by: Ed Santiago <[email protected]>
@Luap99
Copy link
Member

Luap99 commented Jun 7, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 7, 2023
@openshift-merge-robot openshift-merge-robot merged commit c99d42b into containers:main Jun 7, 2023
@edsantiago edsantiago deleted the fix_filters branch June 7, 2023 16:31
@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 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 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. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman stop --filter id=abc : 'abc' should match only at start
5 participants