Commit 5000252e authored by Robert Bailey's avatar Robert Bailey

Merge pull request #12669 from deads2k/tolerate-missing-template-flag

tolerate output without template file
parents a2caee0d 969d526c
...@@ -82,7 +82,10 @@ func OutputVersion(cmd *cobra.Command, defaultVersion string) string { ...@@ -82,7 +82,10 @@ func OutputVersion(cmd *cobra.Command, defaultVersion string) string {
// Requires that printer flags have been added to cmd (see AddPrinterFlags). // Requires that printer flags have been added to cmd (see AddPrinterFlags).
func PrinterForCommand(cmd *cobra.Command) (kubectl.ResourcePrinter, bool, error) { func PrinterForCommand(cmd *cobra.Command) (kubectl.ResourcePrinter, bool, error) {
outputFormat := GetFlagString(cmd, "output") outputFormat := GetFlagString(cmd, "output")
templateFile := GetFlagString(cmd, "template")
// templates are logically optional for specifying a format.
// TODO once https://github.com/kubernetes/kubernetes/issues/12668 is fixed, this should fall back to GetFlagString
templateFile, _ := cmd.Flags().GetString("template")
if len(outputFormat) == 0 && len(templateFile) != 0 { if len(outputFormat) == 0 && len(templateFile) != 0 {
outputFormat = "template" outputFormat = "template"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment