Sort ingresses by creation timestamp

This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-12-19 10:58:42 -03:00
parent cac694ecce
commit b2fa243b97
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
3 changed files with 29 additions and 9 deletions

View file

@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"reflect"
"sort"
"sync"
"time"
@ -736,6 +737,13 @@ func (s *k8sStore) ListIngresses() []*ingress.Ingress {
ingresses = append(ingresses, ing)
}
// sort Ingresses using the CreationTimestamp field
sort.SliceStable(ingresses, func(i, j int) bool {
ir := ingresses[i].CreationTimestamp
jr := ingresses[j].CreationTimestamp
return ir.Before(&jr)
})
return ingresses
}