{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/40076991","id":40076991,"diff_hunk":"@@ -0,0 +1,159 @@\n+/*\n+Copyright 2014 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\"fmt\"\n+\t\"io\"\n+\n+\t\"k8s.io/kubernetes/pkg/api/latest\"\n+\t\"k8s.io/kubernetes/pkg/api/registered\"\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+\n+\t\"github.com/spf13/cobra\"\n+)\n+\n+const (\n+\tconvert_long = `Convert config files between different API versions. Both YAML\n+and JSON formats are accepted.\n+\n+The command takes filename, directory, or URL as input, and convert it into format\n+of version specified by --output-version flag. If target version is not specified or\n+not supported, convert to latest version.\n+\n+The default output will be printed to stdout in YAML format. One can use -o option\n+to change to output destination.\n+`\n+\tconvert_example = `# Convert 'pod.yaml' to latest version and print to stdout.\n+$ kubectl convert -f pod.yaml\n+\n+# Convert the live state of the resource specified by 'pod.yaml' to the latest version\n+# and print to stdout in json format.\n+$ kubectl convert -f pod.yaml --local -o json\n+\n+# Convert all files under current directory to latest version and create them all.\n+$ kubectl convert -f . | kubectl create -f -\n+`\n+)\n+\n+// NewCmdConvert creates a command object for the generic \"convert\" action, which\n+// translates the config file into a given version.\n+func NewCmdConvert(f *cmdutil.Factory, out io.Writer) *cobra.Command {\n+\toptions := &ConvertOptions{}\n+\n+\tcmd := &cobra.Command{\n+\t\tUse:     \"convert -f FILENAME\",\n+\t\tShort:   \"Convert config files between different API versions\",\n+\t\tLong:    convert_long,\n+\t\tExample: convert_example,\n+\t\tRun: func(cmd *cobra.Command, args []string) {\n+\t\t\terr := options.Complete(f, out, cmd, args)\n+\t\t\tcmdutil.CheckErr(err)\n+\t\t\terr = options.RunConvert()\n+\t\t\tcmdutil.CheckErr(err)\n+\t\t},\n+\t}\n+\n+\tusage := \"Filename, directory, or URL to file to need to get converted.\"\n+\tkubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage)\n+\tcmd.MarkFlagRequired(\"filename\")\n+\tcmdutil.AddValidateFlags(cmd)\n+\tcmdutil.AddPrinterFlags(cmd)\n+\tcmd.Flags().BoolVar(&options.local, \"local\", false, \"If true, convert will NOT try to contact api-server but run locally.\")\n+\n+\treturn cmd\n+}\n+\n+// ConvertOptions have the data required to perform the convert operation\n+type ConvertOptions struct {\n+\tbuilder   *resource.Builder\n+\tfilenames []string\n+\tlocal     bool\n+\n+\tout     io.Writer\n+\tprinter kubectl.ResourcePrinter\n+\n+\toutputVersion string\n+}\n+\n+// Complete collects information required to run Convert command from command line.\n+func (o *ConvertOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) (err error) {\n+\to.outputVersion = cmdutil.OutputVersion(cmd, latest.GroupOrDie(\"\").Version)\n+\tif !registered.IsRegisteredAPIVersion(o.outputVersion) {\n+\t\tcmdutil.UsageError(cmd, \"'%s' is not a registered version.\", o.outputVersion)\n+\t}\n+\n+\t// build the builder\n+\tmapper, typer := f.Object()\n+\to.builder = resource.NewBuilder(mapper, typer, f.ClientMapperForCommand())\n+\tenforceNamespace := false\n+\tif o.local {\n+\t\tfmt.Fprintln(out, \"running in local mode...\")\n+\t\to.builder = o.builder.Local()\n+\t} else {\n+\t\tschema, err := f.Validator(cmdutil.GetFlagBool(cmd, \"validate\"), cmdutil.GetFlagString(cmd, \"schema-cache-dir\"))\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tcmdNamespace, enforce, err := f.DefaultNamespace()\n+\t\tenforceNamespace = enforce\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\to.builder = o.builder.Schema(schema).\n+\t\t\tNamespaceParam(cmdNamespace).DefaultNamespace()\n+\t}\n+\to.builder = o.builder.ContinueOnError().\n+\t\tFilenameParam(enforceNamespace, o.filenames...).\n+\t\tFlatten()\n+\n+\t// build the printer\n+\toutputFormat := cmdutil.GetFlagString(cmd, \"output\")\n+\ttemplateFile := cmdutil.GetFlagString(cmd, \"template\")\n+\tif len(outputFormat) == 0 {\n+\t\tif len(templateFile) == 0 {\n+\t\t\toutputFormat = \"yaml\"\n+\t\t} else {\n+\t\t\toutputFormat = \"template\"\n+\t\t}\n+\t}\n+\n+\to.printer, _, err = kubectl.GetPrinter(outputFormat, templateFile)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\treturn nil\n+}\n+\n+// RunConvert implements the generic Convert command\n+func (o *ConvertOptions) RunConvert() error {\n+\n+\tinfos, err := o.builder.Do().Infos()\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\tobjects, err := resource.AsVersionedObject(infos, false, o.outputVersion)","path":"pkg/kubectl/cmd/convert.go","position":153,"original_position":153,"commit_id":"d5355186a03456f48f158c64cd9058bd6092c17f","original_commit_id":"d5355186a03456f48f158c64cd9058bd6092c17f","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":"> For visiting, we don't need to preserve nested list (user said they wanted\r\n> to walk lists implicitly).  In the future we could maybe  have nested, but\r\n> I don't know what concrete reason for that (the output is always a list of\r\n> items)\r\n\r\nOk.  If its a problem in usage, we can change it later.","created_at":"2015-09-22T11:51:32Z","updated_at":"2015-09-22T11:51:32Z","html_url":"https://github.com/kubernetes/kubernetes/pull/11368#discussion_r40076991","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/11368","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/40076991"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/11368#discussion_r40076991"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/11368"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/11368","id":40110069,"html_url":"https://github.com/kubernetes/kubernetes/pull/11368","diff_url":"https://github.com/kubernetes/kubernetes/pull/11368.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/11368.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/11368","number":11368,"state":"open","locked":false,"title":"Integrate conversion tool to kubectl","user":{"login":"hurf","id":4618015,"avatar_url":"https://avatars.githubusercontent.com/u/4618015?v=3","gravatar_id":"","url":"https://api.github.com/users/hurf","html_url":"https://github.com/hurf","followers_url":"https://api.github.com/users/hurf/followers","following_url":"https://api.github.com/users/hurf/following{/other_user}","gists_url":"https://api.github.com/users/hurf/gists{/gist_id}","starred_url":"https://api.github.com/users/hurf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hurf/subscriptions","organizations_url":"https://api.github.com/users/hurf/orgs","repos_url":"https://api.github.com/users/hurf/repos","events_url":"https://api.github.com/users/hurf/events{/privacy}","received_events_url":"https://api.github.com/users/hurf/received_events","type":"User","site_admin":false},"body":"Fixes: #10382\r\n\r\nAdded 'convert' subcommand to kubectl to convert config files\r\nbetween different API versions.","created_at":"2015-07-16T09:27:35Z","updated_at":"2015-09-22T11:51:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"707582d7f2c90ea7fd83542c25a9c190563b95f4","assignee":{"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},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/11368/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/11368/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/11368/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/d5355186a03456f48f158c64cd9058bd6092c17f","head":{"label":"hurf:ctl_convert","ref":"ctl_convert","sha":"d5355186a03456f48f158c64cd9058bd6092c17f","user":{"login":"hurf","id":4618015,"avatar_url":"https://avatars.githubusercontent.com/u/4618015?v=3","gravatar_id":"","url":"https://api.github.com/users/hurf","html_url":"https://github.com/hurf","followers_url":"https://api.github.com/users/hurf/followers","following_url":"https://api.github.com/users/hurf/following{/other_user}","gists_url":"https://api.github.com/users/hurf/gists{/gist_id}","starred_url":"https://api.github.com/users/hurf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hurf/subscriptions","organizations_url":"https://api.github.com/users/hurf/orgs","repos_url":"https://api.github.com/users/hurf/repos","events_url":"https://api.github.com/users/hurf/events{/privacy}","received_events_url":"https://api.github.com/users/hurf/received_events","type":"User","site_admin":false},"repo":{"id":32061334,"name":"kubernetes","full_name":"hurf/kubernetes","owner":{"login":"hurf","id":4618015,"avatar_url":"https://avatars.githubusercontent.com/u/4618015?v=3","gravatar_id":"","url":"https://api.github.com/users/hurf","html_url":"https://github.com/hurf","followers_url":"https://api.github.com/users/hurf/followers","following_url":"https://api.github.com/users/hurf/following{/other_user}","gists_url":"https://api.github.com/users/hurf/gists{/gist_id}","starred_url":"https://api.github.com/users/hurf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hurf/subscriptions","organizations_url":"https://api.github.com/users/hurf/orgs","repos_url":"https://api.github.com/users/hurf/repos","events_url":"https://api.github.com/users/hurf/events{/privacy}","received_events_url":"https://api.github.com/users/hurf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hurf/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/hurf/kubernetes","forks_url":"https://api.github.com/repos/hurf/kubernetes/forks","keys_url":"https://api.github.com/repos/hurf/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hurf/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hurf/kubernetes/teams","hooks_url":"https://api.github.com/repos/hurf/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/hurf/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/hurf/kubernetes/events","assignees_url":"https://api.github.com/repos/hurf/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/hurf/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/hurf/kubernetes/tags","blobs_url":"https://api.github.com/repos/hurf/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hurf/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hurf/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/hurf/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hurf/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/hurf/kubernetes/languages","stargazers_url":"https://api.github.com/repos/hurf/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/hurf/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/hurf/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/hurf/kubernetes/subscription","commits_url":"https://api.github.com/repos/hurf/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/hurf/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/hurf/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/hurf/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/hurf/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/hurf/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hurf/kubernetes/merges","archive_url":"https://api.github.com/repos/hurf/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hurf/kubernetes/downloads","issues_url":"https://api.github.com/repos/hurf/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/hurf/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/hurf/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/hurf/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hurf/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/hurf/kubernetes/releases{/id}","created_at":"2015-03-12T06:40:47Z","updated_at":"2015-05-08T10:52:15Z","pushed_at":"2015-09-19T07:53:43Z","git_url":"git://github.com/hurf/kubernetes.git","ssh_url":"git@github.com:hurf/kubernetes.git","clone_url":"https://github.com/hurf/kubernetes.git","svn_url":"https://github.com/hurf/kubernetes","homepage":"http://kubernetes.io","size":109666,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"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":"94e4426cbba2e63908728234fa89498af1ab1fe9","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-09-22T11:07:11Z","pushed_at":"2015-09-22T11:51:07Z","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":426001,"stargazers_count":10374,"watchers_count":10374,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2573,"mirror_url":null,"open_issues_count":1834,"forks":2573,"open_issues":1834,"watchers":10374,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/11368"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/11368"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/11368"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/11368/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/11368/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/11368/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/d5355186a03456f48f158c64cd9058bd6092c17f"}}}}