mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
sort on non-tabular output
This commit is contained in:
parent
0ef96cbaf4
commit
c87cd9c0f6
@ -241,6 +241,8 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
printer = maybeWrapSortingPrinter(printer, isSorting)
|
||||
return printer.PrintObj, nil
|
||||
}
|
||||
|
||||
@ -738,3 +740,13 @@ func shouldGetNewPrinterForMapping(printer printers.ResourcePrinter, lastMapping
|
||||
func cmdSpecifiesOutputFmt(cmd *cobra.Command) bool {
|
||||
return cmdutil.GetFlagString(cmd, "output") != ""
|
||||
}
|
||||
|
||||
func maybeWrapSortingPrinter(printer printers.ResourcePrinter, sortBy string) printers.ResourcePrinter {
|
||||
if len(sortBy) != 0 {
|
||||
return &kubectl.SortingPrinter{
|
||||
Delegate: printer,
|
||||
SortField: fmt.Sprintf("%s", sortBy),
|
||||
}
|
||||
}
|
||||
return printer
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user