{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/32281063","id":32281063,"diff_hunk":"@@ -0,0 +1,153 @@\n+/*\n+Copyright 2015 The Kubernetes Authors All rights reserved.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+    http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*/\n+\n+package jsonpath\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"reflect\"\n+\t\"strconv\"\n+\n+\t\"github.com/golang/glog\"\n+)\n+\n+type JSONPath struct {\n+\tname   string\n+\tparser *Parser\n+}\n+\n+func NewJSONPath(n string) *JSONPath {\n+\treturn &JSONPath{\n+\t\tname: n,\n+\t}\n+}\n+\n+func (j *JSONPath) Parse(text string) (err error) {\n+\tj.parser, err = Parse(j.name, text)\n+\treturn\n+}\n+\n+func (j *JSONPath) Execute(wr io.Writer, data interface{}) error {\n+\tvalue := reflect.ValueOf(data)\n+\tif j.parser == nil {\n+\t\treturn fmt.Errorf(\"%s is an incomplete jsonpath template\", j.name)\n+\t}\n+\tj.walkTree(wr, value)\n+\treturn nil\n+}\n+\n+// walkTree visit the parsed tree from root\n+func (j *JSONPath) walkTree(wr io.Writer, value reflect.Value) {\n+\tfor _, node := range j.parser.Root.Nodes {\n+\t\tj.walk(wr, value, node)\n+\t}\n+}\n+\n+// walk visit subtree rooted at the gived node in DFS order\n+func (j *JSONPath) walk(wr io.Writer, value reflect.Value, node Node) reflect.Value {\n+\tswitch node := node.(type) {\n+\tcase *ListNode:\n+\t\treturn j.evalList(wr, value, node)\n+\tcase *TextNode:\n+\t\treturn j.evalText(wr, value, node.Text)\n+\tcase *FieldNode:\n+\t\treturn j.evalField(value, node.Value)\n+\tcase *ArrayNode:\n+\t\treturn j.evalArray(value, node)\n+\t}\n+\treturn reflect.Value{}","path":"pkg/util/jsonpath/jsonpath.go","position":73,"original_position":73,"commit_id":"4ec1c2579b49b1c24ec7d68ba9474399a2ff2a42","original_commit_id":"4ec1c2579b49b1c24ec7d68ba9474399a2ff2a42","user":{"login":"brendandburns","id":5751682,"avatar_url":"https://avatars.githubusercontent.com/u/5751682?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandburns","html_url":"https://github.com/brendandburns","followers_url":"https://api.github.com/users/brendandburns/followers","following_url":"https://api.github.com/users/brendandburns/following{/other_user}","gists_url":"https://api.github.com/users/brendandburns/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandburns/subscriptions","organizations_url":"https://api.github.com/users/brendandburns/orgs","repos_url":"https://api.github.com/users/brendandburns/repos","events_url":"https://api.github.com/users/brendandburns/events{/privacy}","received_events_url":"https://api.github.com/users/brendandburns/received_events","type":"User","site_admin":false},"body":"is this case expected?  Perhaps convert to returning an error.","created_at":"2015-06-11T23:59:44Z","updated_at":"2015-06-11T23:59:44Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9296#discussion_r32281063","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9296","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/32281063"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9296#discussion_r32281063"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9296"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9296","id":36995632,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9296","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9296.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9296.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/9296","number":9296,"state":"open","locked":false,"title":"JSONPath template language","user":{"login":"daizuozhuo","id":1107525,"avatar_url":"https://avatars.githubusercontent.com/u/1107525?v=3","gravatar_id":"","url":"https://api.github.com/users/daizuozhuo","html_url":"https://github.com/daizuozhuo","followers_url":"https://api.github.com/users/daizuozhuo/followers","following_url":"https://api.github.com/users/daizuozhuo/following{/other_user}","gists_url":"https://api.github.com/users/daizuozhuo/gists{/gist_id}","starred_url":"https://api.github.com/users/daizuozhuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daizuozhuo/subscriptions","organizations_url":"https://api.github.com/users/daizuozhuo/orgs","repos_url":"https://api.github.com/users/daizuozhuo/repos","events_url":"https://api.github.com/users/daizuozhuo/events{/privacy}","received_events_url":"https://api.github.com/users/daizuozhuo/received_events","type":"User","site_admin":false},"body":"@brendandburns Thanks. Here are features in this pull request:\r\ngiven template：hello ${.jq.title}\r\nand struct: {jq: {title: \"world\"}}\r\nwe will get: hello world\r\n\r\nI add quote \"\" function so that user can input string will not be evaluated:\r\nexpression: hello ${\"${\"}\r\noutput: hello ${","created_at":"2015-06-05T02:11:06Z","updated_at":"2015-06-11T23:59:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca4fe97173b5ba8ea3aa674320acd8269ba7d39e","assignee":{"login":"brendandburns","id":5751682,"avatar_url":"https://avatars.githubusercontent.com/u/5751682?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandburns","html_url":"https://github.com/brendandburns","followers_url":"https://api.github.com/users/brendandburns/followers","following_url":"https://api.github.com/users/brendandburns/following{/other_user}","gists_url":"https://api.github.com/users/brendandburns/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandburns/subscriptions","organizations_url":"https://api.github.com/users/brendandburns/orgs","repos_url":"https://api.github.com/users/brendandburns/repos","events_url":"https://api.github.com/users/brendandburns/events{/privacy}","received_events_url":"https://api.github.com/users/brendandburns/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9296/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9296/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/9296/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/4ec1c2579b49b1c24ec7d68ba9474399a2ff2a42","head":{"label":"daizuozhuo:jqtemplate","ref":"jqtemplate","sha":"4ec1c2579b49b1c24ec7d68ba9474399a2ff2a42","user":{"login":"daizuozhuo","id":1107525,"avatar_url":"https://avatars.githubusercontent.com/u/1107525?v=3","gravatar_id":"","url":"https://api.github.com/users/daizuozhuo","html_url":"https://github.com/daizuozhuo","followers_url":"https://api.github.com/users/daizuozhuo/followers","following_url":"https://api.github.com/users/daizuozhuo/following{/other_user}","gists_url":"https://api.github.com/users/daizuozhuo/gists{/gist_id}","starred_url":"https://api.github.com/users/daizuozhuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daizuozhuo/subscriptions","organizations_url":"https://api.github.com/users/daizuozhuo/orgs","repos_url":"https://api.github.com/users/daizuozhuo/repos","events_url":"https://api.github.com/users/daizuozhuo/events{/privacy}","received_events_url":"https://api.github.com/users/daizuozhuo/received_events","type":"User","site_admin":false},"repo":{"id":32569108,"name":"kubernetes","full_name":"daizuozhuo/kubernetes","owner":{"login":"daizuozhuo","id":1107525,"avatar_url":"https://avatars.githubusercontent.com/u/1107525?v=3","gravatar_id":"","url":"https://api.github.com/users/daizuozhuo","html_url":"https://github.com/daizuozhuo","followers_url":"https://api.github.com/users/daizuozhuo/followers","following_url":"https://api.github.com/users/daizuozhuo/following{/other_user}","gists_url":"https://api.github.com/users/daizuozhuo/gists{/gist_id}","starred_url":"https://api.github.com/users/daizuozhuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daizuozhuo/subscriptions","organizations_url":"https://api.github.com/users/daizuozhuo/orgs","repos_url":"https://api.github.com/users/daizuozhuo/repos","events_url":"https://api.github.com/users/daizuozhuo/events{/privacy}","received_events_url":"https://api.github.com/users/daizuozhuo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/daizuozhuo/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/daizuozhuo/kubernetes","forks_url":"https://api.github.com/repos/daizuozhuo/kubernetes/forks","keys_url":"https://api.github.com/repos/daizuozhuo/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/daizuozhuo/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/daizuozhuo/kubernetes/teams","hooks_url":"https://api.github.com/repos/daizuozhuo/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/daizuozhuo/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/daizuozhuo/kubernetes/events","assignees_url":"https://api.github.com/repos/daizuozhuo/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/daizuozhuo/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/daizuozhuo/kubernetes/tags","blobs_url":"https://api.github.com/repos/daizuozhuo/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/daizuozhuo/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/daizuozhuo/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/daizuozhuo/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/daizuozhuo/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/daizuozhuo/kubernetes/languages","stargazers_url":"https://api.github.com/repos/daizuozhuo/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/daizuozhuo/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/daizuozhuo/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/daizuozhuo/kubernetes/subscription","commits_url":"https://api.github.com/repos/daizuozhuo/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/daizuozhuo/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/daizuozhuo/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/daizuozhuo/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/daizuozhuo/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/daizuozhuo/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/daizuozhuo/kubernetes/merges","archive_url":"https://api.github.com/repos/daizuozhuo/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/daizuozhuo/kubernetes/downloads","issues_url":"https://api.github.com/repos/daizuozhuo/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/daizuozhuo/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/daizuozhuo/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/daizuozhuo/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/daizuozhuo/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/daizuozhuo/kubernetes/releases{/id}","created_at":"2015-03-20T07:23:39Z","updated_at":"2015-05-26T15:43:33Z","pushed_at":"2015-06-10T12:38:04Z","git_url":"git://github.com/daizuozhuo/kubernetes.git","ssh_url":"git@github.com:daizuozhuo/kubernetes.git","clone_url":"https://github.com/daizuozhuo/kubernetes.git","svn_url":"https://github.com/daizuozhuo/kubernetes","homepage":"http://kubernetes.io","size":58786,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:gsoc","ref":"gsoc","sha":"521446503a12c23e8dbd8849e35437ea225fd0c3","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"GoogleCloudPlatform/kubernetes","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-06-11T23:58:38Z","pushed_at":"2015-06-11T23:41:55Z","git_url":"git://github.com/GoogleCloudPlatform/kubernetes.git","ssh_url":"git@github.com:GoogleCloudPlatform/kubernetes.git","clone_url":"https://github.com/GoogleCloudPlatform/kubernetes.git","svn_url":"https://github.com/GoogleCloudPlatform/kubernetes","homepage":"http://kubernetes.io","size":275953,"stargazers_count":8311,"watchers_count":8311,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1770,"mirror_url":null,"open_issues_count":1364,"forks":1770,"open_issues":1364,"watchers":8311,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9296"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9296"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/9296"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/9296/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9296/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9296/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/4ec1c2579b49b1c24ec7d68ba9474399a2ff2a42"}}}}