mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Merge pull request #43501 from xingzhou/kube-43126
Automatic merge from submit-queue Use TabWriter to keep output of "kubectl get xx -w" aligned. Use TabWriter to keep output of "kubectl get xx -w" aligned. fixed #43126
This commit is contained in:
commit
cdbfec3148
@ -246,16 +246,19 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
|
|||||||
// print the current object
|
// print the current object
|
||||||
if !isWatchOnly {
|
if !isWatchOnly {
|
||||||
var objsToPrint []runtime.Object
|
var objsToPrint []runtime.Object
|
||||||
|
writer := printers.GetNewTabWriter(out)
|
||||||
|
|
||||||
if isList {
|
if isList {
|
||||||
objsToPrint, _ = meta.ExtractList(obj)
|
objsToPrint, _ = meta.ExtractList(obj)
|
||||||
} else {
|
} else {
|
||||||
objsToPrint = append(objsToPrint, obj)
|
objsToPrint = append(objsToPrint, obj)
|
||||||
}
|
}
|
||||||
for _, objToPrint := range objsToPrint {
|
for _, objToPrint := range objsToPrint {
|
||||||
if err := printer.PrintObj(objToPrint, out); err != nil {
|
if err := printer.PrintObj(objToPrint, writer); err != nil {
|
||||||
return fmt.Errorf("unable to output the provided object: %v", err)
|
return fmt.Errorf("unable to output the provided object: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
writer.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
// print watched changes
|
// print watched changes
|
||||||
|
Loading…
Reference in New Issue
Block a user