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

[Feature] Add support for invert matching #44

Open
batagy opened this issue Nov 12, 2024 · 2 comments
Open

[Feature] Add support for invert matching #44

batagy opened this issue Nov 12, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@batagy
Copy link

batagy commented Nov 12, 2024

Hi,
Thanks for your great kubectl addon!

I have a feature request, to support negate match. That is '-v' argument in grep.

Example, I have two below pods:

pci-ess-webapp-5f4fbc6666-m9pm9
pci-ess-webapp-connection-test

I want to print pods with 'webapp' string in name, except those with names 'connection-test' in it.

Something like this would be useful:

kubectl grep pods webapp -v connection-test

Thanks in advance!
György

@guessi guessi added the enhancement New feature or request label Nov 12, 2024
@guessi
Copy link
Owner

guessi commented Nov 12, 2024

@batagy thanks for your idea

Feature have been implemented with bb152d3 and should be available soon once v1.19.1 release automation done.

@guessi guessi closed this as completed Nov 12, 2024
@batagy
Copy link
Author

batagy commented Nov 12, 2024

Hi @guessi , thanks a lot for fast implementation!

I quickly tested. I meant a bit different function, not the current one. It seems version 1.19.1 does only either match or inverted match, but not the both together.

Let's say below extended example, I have 3 pods:

pci-ess-init-20241108102154-k5crf
pci-ess-webapp-5f4fbc6666-m9pm9
pci-ess-webapp-connection-test

I would like to print pods with 'webapp' string in name, except those with names 'connection-test' in it.
So I don't want to print these two:

pci-ess-init-20241108102154-k5crf
pci-ess-webapp-connection-test

So I positive grep for 'webapp' , and in same command, I negative grep for word 'connection-test'.
I'd get only below printed:

pci-ess-webapp-5f4fbc6666-m9pm9

In current implementation, it seems the addon cannot grep both positive and negative at same time. When I use below command:

kubectl grep pods webapp -v connection-test

then the string after -v is ignored, and what it will do is to invert grep for word 'webapp' and I get the opposite result. The order of '-v' and the argument after it should matter.

Could you might check this?
Thanks
György

@guessi guessi reopened this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants