Fix index out of range error when sorting kubectl get

pull/58/head
Pierre 2018-11-07 11:52:39 +01:00
parent 7fe59165b6
commit 3b6d8e8373
1 changed files with 7 additions and 4 deletions

View File

@ -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
}
}