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

JSONPath template language #9296

Closed
wants to merge 33 commits into from
Closed

Conversation

daizuozhuo
Copy link
Contributor

@brendandburns Thanks. Here are features in this pull request:

  • "" quote string
  • . key operator
  • [] array operator
  • start : end : step slice operator
  • @ current object
  • * wildcard operator
  • ?() array filter
  • .. parent operator
  • [,] array indices as a set
  • range, end keyword

@k8s-bot
Copy link

k8s-bot commented Jun 5, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.


import (
"errors"
"github.com/GoogleCloudPlatform/kubernetes/third_party/golang/parse"
Copy link
Contributor

Choose a reason for hiding this comment

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

please separate out the non std library imports and put them below in a separate section. (see other files for examples of this)

(also, this dependency should be managed with godeps)

@brendandburns brendandburns self-assigned this Jun 5, 2015
@daizuozhuo
Copy link
Contributor Author

@brendandburns Thanks for reviewing my code. I correct all mistakes except for the third_party code problem. Actually, for the third_party code, I write 30% of them and the rest are copied from golang project.

@daizuozhuo
Copy link
Contributor Author

I rewrite parser so the parser code do't need to be put in third party directory.

@brendandburns
Copy link
Contributor

This is failing Shippable, I think we need to rebase the gsoc branch to HEAD (and in general, Shippable doesn't seem to handle testing PRs to branches other than master very well)

@bgrant0607
Copy link
Member

@daizuozhuo Please ping any open PRs and/or issues with current status at least once a week to ensure they don't drop off our radar.

@daizuozhuo
Copy link
Contributor Author

@brendandburns I have finished all features. Could you review it?

@brendandburns
Copy link
Contributor

yes, will look by the end of the week. Thanks!
--brendan

@daizuozhuo
Copy link
Contributor Author

@brendandburns I just added doc.go. Can you take a look at it?

@bgrant0607
Copy link
Member

Thanks.

More examples:

Getting info about last termination(s):

kubectl get pods/pod-w-message -o template -t "{{range .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"

Getting external IP of a service of type LoadBalancer, which I found easier to do with grep than with a template:

kubectl get svc my-nginx -o json | grep \"ip\"

@bgrant0607
Copy link
Member

While awaiting another review on this, you could write another PR that adds this as a new output format to kubectl, such as -o jsonpath.

@erictune erictune added this to the v1.0-post milestone Jul 14, 2015
@pmorie
Copy link
Member

pmorie commented Jul 16, 2015

I would like to eventually use this to specify field references in the downward API.

case *IdentifierNode:
return j.evalIdentifier(value, node)
default:
return value, fmt.Errorf("unexpect Node %v", node)
Copy link
Contributor

Choose a reason for hiding this comment

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

"unexpected Node %v"

@brendandburns
Copy link
Contributor

Few small comments and a request for parser tests for ill-formed input.

@daizuozhuo
Copy link
Contributor Author

@bgrant0607 To get external IP of a service of type LoadBalancer, we can use "{..ip}" to find the key ip recursively in JSONPath.

@brendandburns
Copy link
Contributor

Ok, since we're now in post 1.0, can you rebase this on master, and we can merge it in.

Thanks!
--brendan

@daizuozhuo
Copy link
Contributor Author

@brendandburns Do you mean reopen this pull request on master? If not, can you tell me how to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants