Merge pull request #14502 from deads2k/tolerate-missing-sortby

don't fatal on missing sorting flag
This commit is contained in:
Eric Tune 2015-09-24 14:09:42 -07:00
commit 43b37204ec

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,