mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
Fix index out of range error when sorting kubectl get
This commit is contained in:
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
|
||||
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
Block a user