don't fatal on missing sorting flag

pull/6/head
deads2k 2015-09-24 12:53:33 -04:00
parent 0662141f67
commit dd7ed11fc1
1 changed files with 6 additions and 1 deletions

View File

@ -112,7 +112,12 @@ func PrinterForCommand(cmd *cobra.Command) (kubectl.ResourcePrinter, bool, error
}
func maybeWrapSortingPrinter(cmd *cobra.Command, printer kubectl.ResourcePrinter) kubectl.ResourcePrinter {
sorting := GetFlagString(cmd, "sort-by")
sorting, err := cmd.Flags().GetString("sort-by")
if err != nil {
// error can happen on missing flag or bad flag type. In either case, this command didn't intent to sort
return printer
}
if len(sorting) != 0 {
return &kubectl.SortingPrinter{
Delegate: printer,