mirror of https://github.com/k3s-io/k3s
Fix index out of range error when sorting kubectl get
parent
7fe59165b6
commit
3b6d8e8373
|
@ -314,11 +314,14 @@ type RuntimeSorter struct {
|
|||
}
|
||||
|
||||
func (r *RuntimeSorter) Sort() error {
|
||||
if len(r.objects) <= 1 {
|
||||
// a list is only considered "sorted" if there are 0 or 1 items in it
|
||||
// AND (if 1 item) the item is not a Table object
|
||||
// a list is only considered "sorted" if there are 0 or 1 items in it
|
||||
// AND (if 1 item) the item is not a Table object
|
||||
if len(r.objects) == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(r.objects) == 1 {
|
||||
_, isTable := r.objects[0].(*metav1beta1.Table)
|
||||
if len(r.objects) == 0 || !isTable {
|
||||
if !isTable {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue