mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
don't fatal on missing sorting flag
This commit is contained in:
parent
0662141f67
commit
dd7ed11fc1
@ -112,7 +112,12 @@ func PrinterForCommand(cmd *cobra.Command) (kubectl.ResourcePrinter, bool, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func maybeWrapSortingPrinter(cmd *cobra.Command, printer kubectl.ResourcePrinter) kubectl.ResourcePrinter {
|
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 {
|
if len(sorting) != 0 {
|
||||||
return &kubectl.SortingPrinter{
|
return &kubectl.SortingPrinter{
|
||||||
Delegate: printer,
|
Delegate: printer,
|
||||||
|
Loading…
Reference in New Issue
Block a user