{"action":"opened","issue":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/48738","repository_url":"https://api.github.com/repos/kubernetes/kubernetes","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/48738/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/48738/comments","events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/48738/events","html_url":"https://github.com/kubernetes/kubernetes/issues/48738","id":241884339,"number":48738,"title":"\"kubectl create\" subcommands need to validate printer flags before creating a resource","user":{"login":"alexandercampbell","id":9295657,"avatar_url":"https://avatars2.githubusercontent.com/u/9295657?v=3","gravatar_id":"","url":"https://api.github.com/users/alexandercampbell","html_url":"https://github.com/alexandercampbell","followers_url":"https://api.github.com/users/alexandercampbell/followers","following_url":"https://api.github.com/users/alexandercampbell/following{/other_user}","gists_url":"https://api.github.com/users/alexandercampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/alexandercampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexandercampbell/subscriptions","organizations_url":"https://api.github.com/users/alexandercampbell/orgs","repos_url":"https://api.github.com/users/alexandercampbell/repos","events_url":"https://api.github.com/users/alexandercampbell/events{/privacy}","received_events_url":"https://api.github.com/users/alexandercampbell/received_events","type":"User","site_admin":false},"labels":[{"id":105146071,"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/kind/bug","name":"kind/bug","color":"e11d21","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-10T23:49:40Z","updated_at":"2017-07-10T23:49:40Z","closed_at":null,"body":"<!-- This form is for bug reports and feature requests ONLY! \r\n\r\nIf you're looking for help check [Stack Overflow](https://stackoverflow.com/questions/tagged/kubernetes) and the [troubleshooting guide](https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/).\r\n-->\r\n\r\n/kind bug\r\n\r\n**What happened**:\r\n\r\nI ran\r\n\r\n```bash\r\nkubectl create deployment test-output --image=nginx --output=\"invalid\"\r\n```\r\n\r\nThe deployment \"test-output\" was created, but then I got this error message: `error: output format \"invalid\" not recognized`.\r\n\r\n**What you expected to happen**:\r\n\r\nThe \"kubectl\" command should have errored out immediately when I provided a bad \"--output\" flag.\r\n\r\nThis is because the logic currently runs:\r\n1. Create deployment. [code](https://github.com/kubernetes/kubernetes/blob/0744964956abdb17586361dee59853f6167b58d7/pkg/kubectl/cmd/create.go#L281)\r\n2. Validate the \"--output\" flag (and related printer flags). [code](https://github.com/kubernetes/kubernetes/blob/0744964956abdb17586361dee59853f6167b58d7/pkg/printers/printers.go#L128-L129)\r\n3. Print the deployment info. [code](https://github.com/kubernetes/kubernetes/blob/0744964956abdb17586361dee59853f6167b58d7/pkg/kubectl/cmd/create.go#L298)\r\n\r\nSteps 1 and 2 should be switched.\r\n\r\n**How to reproduce it (as minimally and precisely as possible)**:\r\n\r\nRun the command I gave.\r\n\r\n**Why didn't I just fix this?**:\r\n\r\nBecause the printer system is very complicated and tightly coupled to Cobra.Command. There is no way to validate that the printer flags are valid without actually printing something. A solution might be to make a struct `PrintOptions{}` that can be read from Cobra and validated independently.\r\n\r\nCredit goes to @mengqiy for discovering this issue.\r\n"}}
{"actor":{"display_login":"alexandercampbell"}}