GitHub PullRequestReviewCommentEvent at 2014-10-27 14:47:34
Repository: kubernetes
Actor: smarterclayton
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/19409074","id":19409074,"diff_hunk":"@@ -0,0 +1,91 @@\n+/*\n+Copyright 2014 Google Inc. 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 cmd\n+\n+import (\n+\t\"fmt\"\n+\n+\t\"github.com/spf13/cobra\"\n+\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/api\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl\"\n+)\n+\n+// ResourceFromArgsOrFile expects two arguments or a valid file with a given type, and extracts\n+// the fields necessary to uniquely locate a resource. Displays a usageError if that contract is\n+// not satisfied, or a generic error if any other problems occur.\n+func ResourceFromArgsOrFile(cmd *cobra.Command, args []string, filename string, typer kubectl.ObjectTyper, mapper kubectl.ResourceMapper) (mapping *kubectl.ResourceMapping, namespace, name string) {\n+\t// If command line args are passed in, use those preferentially.\n+\tif len(args) > 0 && len(args) != 2 {\n+\t\tusageError(cmd, \"If passing in command line parameters, must be resource and name\")\n+\t}\n+\n+\tif len(args) == 2 {\n+\t\tresource := args[0]\n+\t\tnamespace = api.NamespaceDefault\n+\t\tname = args[1]\n+\t\tif len(name) == 0 || len(resource) == 0 {\n+\t\t\tusageError(cmd, \"Must specify filename or command line params\")\n+\t\t}\n+\n+\t\tversion, kind, err := mapper.VersionAndKindForResource(resource)\n+\t\tcheckErr(err)\n+\n+\t\tmapping, err = mapper.ResourceMapping(version, kind)\n+\t\tcheckErr(err)\n+\t\treturn\n+\t}\n+\n+\tif len(filename) == 0 {\n+\t\tusageError(cmd, \"Must specify filename or command line params\")\n+\t}\n+\n+\tmapping, namespace, name, _ = ResourceFromFile(filename, typer, mapper)\n+\tif len(name) == 0 {\n+\t\tcheckErr(fmt.Errorf(\"The resource in the provided file has no name (or ID) defined\"))\n+\t}\n+\n+\treturn\n+}\n+\n+func ResourceFromFile(filename string, typer kubectl.ObjectTyper, mapper kubectl.ResourceMapper) (mapping *kubectl.ResourceMapping, namespace, name string, data []byte) {\n+\tconfigData, err := readConfigData(filename)\n+\tcheckErr(err)\n+\tdata = configData\n+\n+\tversion, kind, err := typer.DataVersionAndKind(data)\n+\tcheckErr(err)\n+\n+\t// TODO: allow unversioned objects?","path":"pkg/kubectl/cmd/resource.go","position":73,"original_position":73,"commit_id":"392358db88f74255190b24e84ca14e5021151c0a","original_commit_id":"392358db88f74255190b24e84ca14e5021151c0a","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=2","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"That doesn't work well in practice and will change unpredictably.  I don't want people relying on it right now because it's error prone.\n\n----- Original Message -----\n> > +\tif len(name) == 0 {\n> > +\t\tcheckErr(fmt.Errorf(\"The resource in the provided file has no name (or\n> > ID) defined\"))\n> > +\t}\n> > +\n> > +\treturn\n> > +}\n> > +\n> > +func ResourceFromFile(filename string, typer kubectl.ObjectTyper, mapper\n> > kubectl.ResourceMapper) (mapping *kubectl.ResourceMapping, namespace, name\n> > string, data []byte) {\n> > +\tconfigData, err := readConfigData(filename)\n> > +\tcheckErr(err)\n> > +\tdata = configData\n> > +\n> > +\tversion, kind, err := typer.DataVersionAndKind(data)\n> > +\tcheckErr(err)\n> > +\n> > +\t// TODO: allow unversioned objects?\n> \n> `latest` version as default?\n> \n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/GoogleCloudPlatform/kubernetes/pull/2000/files#r19408916","created_at":"2014-10-27T14:47:34Z","updated_at":"2014-10-27T14:47:34Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/2000#discussion_r19409074","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/2000","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/19409074"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/2000#discussion_r19409074"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/2000"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/2000","id":23362324,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/2000","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/2000.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/2000.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/2000","number":2000,"state":"open","locked":false,"title":"WIP - Allow kubectl to handle arbitrary objects","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=2","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"Kubectl will need to handle extension of object types for known (part of api.Scheme)\nand unknown (defined via config or future ComponentPlugin extension mechanisms) from\nthe API server.  This pull request updates the create/update/delete flows for kubectl\nto separate the versioning abstractions from the core code path via interfaces.\n\nI will update the other code paths (get / describe) once we get through this review.\n@ghodss @fabianofranz\n\nThe pull also contains unification of ResourceVersioner and SelfLinker and starts\nusing it within Kubectl. @lavalamp","created_at":"2014-10-27T03:57:58Z","updated_at":"2014-10-27T14:47:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b2afc7de9974b89ac3a0dac7b66aa5063e16f32","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/2000/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/2000/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/{number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/2000/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/392358db88f74255190b24e84ca14e5021151c0a","head":{"label":"smarterclayton:client_takes_multiple_types","ref":"client_takes_multiple_types","sha":"392358db88f74255190b24e84ca14e5021151c0a","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=2","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"repo":{"id":21225407,"name":"kubernetes","full_name":"smarterclayton/kubernetes","owner":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=2","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smarterclayton/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/smarterclayton/kubernetes","forks_url":"https://api.github.com/repos/smarterclayton/kubernetes/forks","keys_url":"https://api.github.com/repos/smarterclayton/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smarterclayton/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smarterclayton/kubernetes/teams","hooks_url":"https://api.github.com/repos/smarterclayton/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/smarterclayton/kubernetes/events","assignees_url":"https://api.github.com/repos/smarterclayton/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/smarterclayton/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/smarterclayton/kubernetes/tags","blobs_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smarterclayton/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/smarterclayton/kubernetes/languages","stargazers_url":"https://api.github.com/repos/smarterclayton/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/smarterclayton/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/smarterclayton/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/smarterclayton/kubernetes/subscription","commits_url":"https://api.github.com/repos/smarterclayton/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/smarterclayton/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues/comments/{number}","contents_url":"https://api.github.com/repos/smarterclayton/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/smarterclayton/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smarterclayton/kubernetes/merges","archive_url":"https://api.github.com/repos/smarterclayton/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smarterclayton/kubernetes/downloads","issues_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/smarterclayton/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/smarterclayton/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/smarterclayton/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smarterclayton/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/smarterclayton/kubernetes/releases{/id}","created_at":"2014-06-26T02:28:13Z","updated_at":"2014-06-26T01:04:38Z","pushed_at":"2014-10-27T04:02:55Z","git_url":"git://github.com/smarterclayton/kubernetes.git","ssh_url":"git@github.com:smarterclayton/kubernetes.git","clone_url":"https://github.com/smarterclayton/kubernetes.git","svn_url":"https://github.com/smarterclayton/kubernetes","homepage":null,"size":14823,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"dc7e3d6601a89e9017ca9db42c09fd0ecb36bb36","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=2","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=2","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","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":"2014-10-27T13:16:18Z","pushed_at":"2014-10-24T23:26:17Z","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":null,"size":44127,"stargazers_count":4152,"watchers_count":4152,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":624,"mirror_url":null,"open_issues_count":339,"forks":624,"open_issues":339,"watchers":4152,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/2000"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/2000"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/2000"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/2000/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/2000/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/2000/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/392358db88f74255190b24e84ca14e5021151c0a"}}}}