mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #12669 from deads2k/tolerate-missing-template-flag
tolerate output without template file
This commit is contained in:
commit
5000252e46
@ -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"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user