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

Implement the --filter flag for images command. #1359

Merged
merged 1 commit into from
Feb 22, 2024
Merged

Implement the --filter flag for images command. #1359

merged 1 commit into from
Feb 22, 2024

Conversation

roman-kiselenko
Copy link
Contributor

The following filters are available:

  1. dangling=(true/false)
  2. reference=regex
  3. before=<image-name>[:<tag>]|<image id>|<image@digest>
  4. since=<image-name>[:<tag>]|<image id>|<image@digest>

What type of PR is this?

/kind documentation
/kind feature

What this PR does / why we need it:

Filtering images is a good feature for cluster admins; we need a filter flag for the crictl images command to reduce shell scripts complexity.

Which issue(s) this PR fixes:

Fixes #1256

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

None

Implemented the `--filter` flag for `crictl images` command.
The following filters are available:

1. `dangling=(true/false)`
2. `reference=regex`
3. `before=<image-name>[:<tag>]|<image id>|<image@digest>`
4. `since=<image-name>[:<tag>]|<image id>|<image@digest>`

/c @kubernetes-sigs/cri-tools

@k8s-ci-robot k8s-ci-robot added kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. labels Feb 20, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 20, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @roman-kiselenko!

It looks like this is your first PR to kubernetes-sigs/cri-tools 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cri-tools has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 20, 2024
@roman-kiselenko
Copy link
Contributor Author

/c @saschagrunert @kwilczynski

cmd/crictl/image.go Outdated Show resolved Hide resolved
@roman-kiselenko
Copy link
Contributor Author

What is wrong with docs/ctrctl.1 🤔 ?

@kwilczynski
Copy link
Member

@roman-kiselenko, thank you! This is great! 🚀

@kwilczynski
Copy link
Member

What is wrong with docs/ctrctl.1 🤔 ?

@roman-kiselenko, you might have to generate an updated version. Would be my guess.

This would be to reflect the new command-line argument addition, etc.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 21, 2024
@roman-kiselenko
Copy link
Contributor Author

What is wrong with docs/ctrctl.1 🤔 ?

@roman-kiselenko, you might have to generate an updated version. Would be my guess.

This would be to reflect the new command-line argument addition, etc.

Thanks 🙏 docs are updated. go-md2man -in docs/crictl.md -out docs/crictl.1

The following filters are available:

1. `dangling=(true/false)`
2. `reference=regex`
3. `before=<image-name>[:<tag>]|<image id>|<image@digest>`
4. `since=<image-name>[:<tag>]|<image id>|<image@digest>`

Signed-off-by: roman-kiselenko <roman.kiselenko.dev@gmail.com>
@kwilczynski
Copy link
Member

/retitle Implement the --filter flag for images command

@k8s-ci-robot
Copy link
Contributor

@kwilczynski: Re-titling can only be requested by trusted users, like repository collaborators.

In response to this:

/retitle Implement the --filter flag for images command

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.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: roman-kiselenko, saschagrunert

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

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 22, 2024
@k8s-ci-robot k8s-ci-robot merged commit 7c196c0 into kubernetes-sigs:master Feb 22, 2024
23 checks passed
case strings.HasPrefix(filter, "since="):
filtered = filterByBeforeSince(strings.TrimPrefix(filter, "since="), filtered)
default:
return []*pb.Image{}, fmt.Errorf("Unknown filter flag: %v", filter)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return []*pb.Image{}, fmt.Errorf("Unknown filter flag: %v", filter)
return []*pb.Image{}, fmt.Errorf("unknown filter flag: %s", filter)

cmd/crictl/image.go Show resolved Hide resolved
cmd/crictl/image.go Show resolved Hide resolved
docs/crictl.md Show resolved Hide resolved
docs/crictl.md Show resolved Hide resolved
docs/crictl.md Show resolved Hide resolved
cmd/crictl/image.go Show resolved Hide resolved
docs/crictl.md Show resolved Hide resolved
@kwilczynski
Copy link
Member

@roman-kiselenko, I am sorry for the late review!

@saschagrunert made me realise that I forgot to submit my review comments earlier. Doh!

Let me know what you think about some of the comments.

@roman-kiselenko
Copy link
Contributor Author

@roman-kiselenko, I am sorry for the late review!

@saschagrunert made me realise that I forgot to submit my review comments earlier. Doh!

Let me know what you think about some of the comments.

@kwilczynski

no problem at all, I'll take care of your comments in another PR 😁

@roman-kiselenko roman-kiselenko changed the title Implemented the --filter flag for images command. Implement the --filter flag for images command. Feb 23, 2024
@roman-kiselenko roman-kiselenko deleted the feature/support-image-filters branch February 23, 2024 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support filter in crictl images
5 participants