{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/41014353","id":41014353,"diff_hunk":"@@ -0,0 +1,224 @@\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 cmd\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"github.com/spf13/cobra\"\n+\t\"io\"\n+\n+\t\"k8s.io/kubernetes/pkg/api/meta\"\n+\t\"k8s.io/kubernetes/pkg/kubectl\"\n+\tcmdutil \"k8s.io/kubernetes/pkg/kubectl/cmd/util\"\n+\t\"k8s.io/kubernetes/pkg/kubectl/resource\"\n+\t\"k8s.io/kubernetes/pkg/runtime\"\n+)\n+\n+const (\n+\tnew_long = `Create a new object of the given type using a template.\n+\n+The new command pulls down an example for the given object type, allows\n+you to edit the filled in example, and then submits it for creation.  The\n+editing functionality functions similarly to the 'edit' command -- you\n+can control the editor used, as well as the format and version, using\n+the same flags and environment variables.\n+\n+By default, before submission your new object will be validated.  If an\n+invalid object is encountered, you will be returned to the editor with the\n+invalid part indicated with comments.  Use the '--validate=false' in order\n+to skip local validation.\n+\n+You can specify namespace, name, and labels (in 'key1=value1,key2=value2' form)\n+from the command line using the '--namespace', '--name', and '--labels' flags.\n+\n+You can use the '--dry-run' flag to just output the example to standard out\n+without launching an editor or submitting the object for creation.\n+`\n+\n+\tnew_example = `# Create a new pod named 'website':\n+  $ kubectl new pod --name website --labels end=front,app=site\n+\n+  # Don't validate the object before creation\n+  $ kubectl new namespace --validate=false --name my-ns\n+\n+  # Don't edit or create a new object -- just output the example\n+  $ kubectl new namespace --name my-ns --dry-run`\n+)\n+\n+func NewCmdNew(f *cmdutil.Factory, out io.Writer) *cobra.Command {\n+\tcmd := &cobra.Command{\n+\t\tUse:     \"new TYPE [--name NAME] [--labels key1=val,key2=val]\",","path":"pkg/kubectl/cmd/new.go","position":65,"original_position":65,"commit_id":"503a40deb48d136b9a4be6cd18f200d500465297","original_commit_id":"503a40deb48d136b9a4be6cd18f200d500465297","user":{"login":"deads2k","id":8225098,"avatar_url":"https://avatars.githubusercontent.com/u/8225098?v=3","gravatar_id":"","url":"https://api.github.com/users/deads2k","html_url":"https://github.com/deads2k","followers_url":"https://api.github.com/users/deads2k/followers","following_url":"https://api.github.com/users/deads2k/following{/other_user}","gists_url":"https://api.github.com/users/deads2k/gists{/gist_id}","starred_url":"https://api.github.com/users/deads2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads2k/subscriptions","organizations_url":"https://api.github.com/users/deads2k/orgs","repos_url":"https://api.github.com/users/deads2k/repos","events_url":"https://api.github.com/users/deads2k/events{/privacy}","received_events_url":"https://api.github.com/users/deads2k/received_events","type":"User","site_admin":false},"body":"What about having subcommands for known types that give nicer arguments.  For instance, having a `--replicas` for RC and `--secret=key:value` for Secrets would be really nice.  I like having something generic too, but setting the structure like this precludes providing really nice `kubectl new` functionality for well known types.","created_at":"2015-10-02T12:01:12Z","updated_at":"2015-10-02T12:01:12Z","html_url":"https://github.com/kubernetes/kubernetes/pull/14294#discussion_r41014353","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/14294","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/41014353"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/14294#discussion_r41014353"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/14294"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/14294","id":45587825,"html_url":"https://github.com/kubernetes/kubernetes/pull/14294","diff_url":"https://github.com/kubernetes/kubernetes/pull/14294.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/14294.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/14294","number":14294,"state":"open","locked":false,"title":"[WIP] Introduce the 'new' Command","user":{"login":"DirectXMan12","id":119737,"avatar_url":"https://avatars.githubusercontent.com/u/119737?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectXMan12","html_url":"https://github.com/DirectXMan12","followers_url":"https://api.github.com/users/DirectXMan12/followers","following_url":"https://api.github.com/users/DirectXMan12/following{/other_user}","gists_url":"https://api.github.com/users/DirectXMan12/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectXMan12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectXMan12/subscriptions","organizations_url":"https://api.github.com/users/DirectXMan12/orgs","repos_url":"https://api.github.com/users/DirectXMan12/repos","events_url":"https://api.github.com/users/DirectXMan12/events{/privacy}","received_events_url":"https://api.github.com/users/DirectXMan12/received_events","type":"User","site_admin":false},"body":"This PR introduces the `new` command, which allows users to create new objects by dumping an 'example' object into an editor, and then letting the user edit the object before creation.  The actually edit functionality was pulled from the new `edit` command.\r\n\r\nThe original intent was to store examples in Swagger, but unfortunately, go-restful doesn't support the latest version of the Swagger spec, and thus does not support the `example` field on models.  Therefore, this PR presents implementations of two different ways of adding examples in the mean time -- one in which API objects are annotated with the `example` tag (and then reflection is used to generate the example), and another in which examples are \"registered\" with the API `Scheme`, similarly to how default functions and conversion functions work.\r\n\r\nPart of #10495 ","created_at":"2015-09-21T19:16:53Z","updated_at":"2015-10-02T12:01:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"11012f78b27a210e087fea4de6092fc10786f738","assignee":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","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},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/14294/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/14294/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/14294/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/503a40deb48d136b9a4be6cd18f200d500465297","head":{"label":"DirectXMan12:feature/new-command","ref":"feature/new-command","sha":"503a40deb48d136b9a4be6cd18f200d500465297","user":{"login":"DirectXMan12","id":119737,"avatar_url":"https://avatars.githubusercontent.com/u/119737?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectXMan12","html_url":"https://github.com/DirectXMan12","followers_url":"https://api.github.com/users/DirectXMan12/followers","following_url":"https://api.github.com/users/DirectXMan12/following{/other_user}","gists_url":"https://api.github.com/users/DirectXMan12/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectXMan12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectXMan12/subscriptions","organizations_url":"https://api.github.com/users/DirectXMan12/orgs","repos_url":"https://api.github.com/users/DirectXMan12/repos","events_url":"https://api.github.com/users/DirectXMan12/events{/privacy}","received_events_url":"https://api.github.com/users/DirectXMan12/received_events","type":"User","site_admin":false},"repo":{"id":39400877,"name":"kubernetes","full_name":"DirectXMan12/kubernetes","owner":{"login":"DirectXMan12","id":119737,"avatar_url":"https://avatars.githubusercontent.com/u/119737?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectXMan12","html_url":"https://github.com/DirectXMan12","followers_url":"https://api.github.com/users/DirectXMan12/followers","following_url":"https://api.github.com/users/DirectXMan12/following{/other_user}","gists_url":"https://api.github.com/users/DirectXMan12/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectXMan12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectXMan12/subscriptions","organizations_url":"https://api.github.com/users/DirectXMan12/orgs","repos_url":"https://api.github.com/users/DirectXMan12/repos","events_url":"https://api.github.com/users/DirectXMan12/events{/privacy}","received_events_url":"https://api.github.com/users/DirectXMan12/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DirectXMan12/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/DirectXMan12/kubernetes","forks_url":"https://api.github.com/repos/DirectXMan12/kubernetes/forks","keys_url":"https://api.github.com/repos/DirectXMan12/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DirectXMan12/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DirectXMan12/kubernetes/teams","hooks_url":"https://api.github.com/repos/DirectXMan12/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/DirectXMan12/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/DirectXMan12/kubernetes/events","assignees_url":"https://api.github.com/repos/DirectXMan12/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/DirectXMan12/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/DirectXMan12/kubernetes/tags","blobs_url":"https://api.github.com/repos/DirectXMan12/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DirectXMan12/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DirectXMan12/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/DirectXMan12/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DirectXMan12/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/DirectXMan12/kubernetes/languages","stargazers_url":"https://api.github.com/repos/DirectXMan12/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/DirectXMan12/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/DirectXMan12/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/DirectXMan12/kubernetes/subscription","commits_url":"https://api.github.com/repos/DirectXMan12/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/DirectXMan12/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/DirectXMan12/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/DirectXMan12/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/DirectXMan12/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/DirectXMan12/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DirectXMan12/kubernetes/merges","archive_url":"https://api.github.com/repos/DirectXMan12/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DirectXMan12/kubernetes/downloads","issues_url":"https://api.github.com/repos/DirectXMan12/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/DirectXMan12/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/DirectXMan12/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/DirectXMan12/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DirectXMan12/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/DirectXMan12/kubernetes/releases{/id}","created_at":"2015-07-20T18:22:30Z","updated_at":"2015-07-20T18:22:36Z","pushed_at":"2015-10-01T17:47:19Z","git_url":"git://github.com/DirectXMan12/kubernetes.git","ssh_url":"git@github.com:DirectXMan12/kubernetes.git","clone_url":"https://github.com/DirectXMan12/kubernetes.git","svn_url":"https://github.com/DirectXMan12/kubernetes","homepage":"http://kubernetes.io","size":111450,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"a463b34507a305f1fb94398e7e77ff55826c1a4d","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"kubernetes/kubernetes","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/kubernetes/kubernetes","forks_url":"https://api.github.com/repos/kubernetes/kubernetes/forks","keys_url":"https://api.github.com/repos/kubernetes/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/kubernetes/teams","hooks_url":"https://api.github.com/repos/kubernetes/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/kubernetes/events","assignees_url":"https://api.github.com/repos/kubernetes/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/kubernetes/tags","blobs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/kubernetes/languages","stargazers_url":"https://api.github.com/repos/kubernetes/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/kubernetes/subscription","commits_url":"https://api.github.com/repos/kubernetes/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/kubernetes/merges","archive_url":"https://api.github.com/repos/kubernetes/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/kubernetes/downloads","issues_url":"https://api.github.com/repos/kubernetes/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-10-02T11:53:35Z","pushed_at":"2015-10-02T11:54:54Z","git_url":"git://github.com/kubernetes/kubernetes.git","ssh_url":"git@github.com:kubernetes/kubernetes.git","clone_url":"https://github.com/kubernetes/kubernetes.git","svn_url":"https://github.com/kubernetes/kubernetes","homepage":"http://kubernetes.io","size":442910,"stargazers_count":10526,"watchers_count":10526,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2643,"mirror_url":null,"open_issues_count":1993,"forks":2643,"open_issues":1993,"watchers":10526,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/14294"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/14294"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/14294"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/14294/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/14294/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/14294/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/503a40deb48d136b9a4be6cd18f200d500465297"}}}}