kubernetes / kubectl

Issue tracker and mirror of kubectl code
Apache License 2.0
2.86k stars 921 forks source link

Jsonpath: add support for OR operation in list filters #1341

Open rodrigovb96 opened 1 year ago

rodrigovb96 commented 1 year ago

JsonPath describes a "or operation" for list filters that is not implemented in kubectl

I would like to add the possibility to do the following:

kubectl get deploy -o jsonpath='{.items[?(@.metadata.name=="foo") || ?(@.metadata.name=="bar")].metadata.name}

With this feature one could do more complex filtering without having to do more than one kubectl request

ardaguclu commented 1 year ago

I don't know if it is possible or not;

@mpuckett159 WDYT?

mpuckett159 commented 1 year ago

It's definitely not possible with the current jsonpath library but I am seeing about either improving the current implementation of our in tree jsonpath library to support this (hard) or importing an external module to allow for this to be possible (easy). I made some minimal progress a few months ago but had to put it on the back burner and hope to get back to it shortly.

rodrigovb96 commented 1 year ago

Thank you for the quick response, @mpuckett159 can you share which external module is that?

mpuckett159 commented 1 year ago

Oh I didn't even notice this was a recent issue, this comes up quite often haha.

https://github.com/ohler55/ojg

Not exactly sure if this will be acceptable from the maintainers but I have discussed it with them.

mpuckett159 commented 1 year ago

/triage accepted /priority backlog

k8s-triage-robot commented 9 months ago

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

k8s-triage-robot commented 6 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

rodrigovb96 commented 6 months ago

/remove-lifecycle stale

k8s-triage-robot commented 3 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

rodrigovb96 commented 3 months ago

/remove-lifecycle stale

k8s-triage-robot commented 2 weeks ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale