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

Document how to negate a jsonpath conditional #7853

Closed
1 of 2 tasks
rcorre opened this issue Mar 26, 2018 · 12 comments
Closed
1 of 2 tasks

Document how to negate a jsonpath conditional #7853

rcorre opened this issue Mar 26, 2018 · 12 comments
Assignees
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/docs Categorizes an issue or PR as relevant to SIG Docs.

Comments

@rcorre
Copy link
Contributor

rcorre commented Mar 26, 2018

This is a...

  • Feature Request
  • Bug Report

Problem:

kubectl get ns -ojsonpath='{range .items[?(@.metadata.labels.origin)]}{.metadata.name}{"\n"}'

lists namespaces that have the label "origin". How do I list namespaces that don't have the label "origin"?

The jsonpath docs provided by kubernetes.io are very sparse, and pretty much say "we support jsonpath plus a few extra features". There's no link to the official "jsonpath" docs, so I had to search and eventually found my way to http://goessner.net/articles/JsonPath/. That pretty much says "jsonpath is like xpath" without giving a full description of the syntax, so I then found my way to https://en.wikipedia.org/wiki/XPath.

That finally seemed to be comprehensive syntax documentation, yet doesn't seem compatible with k8s. For my above example, I would expect the boolean function not to work, yet

kubectl get ns -ojsonpath='{range .items[?(not(@.metadata.labels.origin))]}{.metadata.name}{"\n"}'

fails with error: error parsing jsonpath {range .items[?(not(@.metadata.labels.origin))]}{.metadata.name}{"\n"}, unclosed array expect ].

Proposed Solution:

Include full jsonpath syntax documentation, or link to a page that documents jsonpath in a way that is compatible with k8s. Alternately, if kubectl does not really support jsonpath, the line "And we add three functions in addition to the original JSONPath syntax" should be changed to reflect that.

Page to Update:
https://kubernetes.io/docs/reference/kubectl/jsonpath/

Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T21:07:38Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.5", GitCommit:"f01a2bf98249a4db383560443a59bed0c13575df", GitTreeState:"clean", BuildDate:"2018-03-19T15:50:45Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
@zacharysarah zacharysarah added P2 sig/docs Categorizes an issue or PR as relevant to SIG Docs. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Mar 26, 2018
@zacharysarah
Copy link
Contributor

/assign @steveperry-53
/assign @tengqm

@zacharysarah zacharysarah added sig/docs Categorizes an issue or PR as relevant to SIG Docs. and removed sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Mar 26, 2018
@tengqm
Copy link
Contributor

tengqm commented Mar 27, 2018

Looks like there are many variants of jsonpath implementation. The one kubectl is using is very basic one. Regarding the filtering function, you can find the implementation here: https://github.com/kubernetes/client-go/blob/master/util/jsonpath/parser.go#L339

So ... there is currently no support to logical negation. I'm not aware of any official standard saying that JsonPath is compatible to XPath. Maybe I'm wrong.

@rcorre
Copy link
Contributor Author

rcorre commented Mar 27, 2018

When I search for "jsonpath", my first hit is http://goessner.net/articles/JsonPath/. I guess it doesn't quite state that JsonPath is compatible with XPath, but it frequently references XPath and doesn't have a full reference of its own (e.g. it doesn't even mention ==).

The one kubectl is using is very basic one

Could the jsonpath docs include a link to whichever standard this is, or its own documentation if kubectl isn't conforming to any existing standard? As it stands right now, the docs refer to the "original JSONPath syntax" without actually stating what that is, which leaves readers to go off searching and find different things.

Thanks for the link to the source!

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 25, 2018
@rcorre
Copy link
Contributor Author

rcorre commented Jun 25, 2018

/remove-lifecycle stale

I think my above comment still stands:

Could the jsonpath docs include a link to whichever standard this is, or its own documentation if kubectl isn't conforming to any existing standard? As it stands right now, the docs refer to the "original JSONPath syntax" without actually stating what that is, which leaves readers to go off searching and find different things.

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 25, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 23, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 23, 2018
@rcorre
Copy link
Contributor Author

rcorre commented Oct 23, 2018

/remove-lifecycle rotten

Could the jsonpath docs include a link to whichever standard this is, or its own documentation if kubectl isn't conforming to any existing standard? As it stands right now, the docs refer to the "original JSONPath syntax" without actually stating what that is, which leaves readers to go off searching and find different things.

Does anyone know what "original JSONPath syntax" refers to?

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Oct 23, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 21, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 20, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/docs Categorizes an issue or PR as relevant to SIG Docs.
Projects
None yet
Development

No branches or pull requests

6 participants