...
1
16
17 package sliceutils
18
19 import (
20 v1 "k8s.io/api/core/v1"
21 kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
22 )
23
24
25
26 type PodsByCreationTime []*v1.Pod
27
28 func (s PodsByCreationTime) Len() int {
29 return len(s)
30 }
31
32 func (s PodsByCreationTime) Swap(i, j int) {
33 s[i], s[j] = s[j], s[i]
34 }
35
36 func (s PodsByCreationTime) Less(i, j int) bool {
37 return s[i].CreationTimestamp.Before(&s[j].CreationTimestamp)
38 }
39
40
41
42 type ByImageSize []kubecontainer.Image
43
44 func (a ByImageSize) Less(i, j int) bool {
45 if a[i].Size == a[j].Size {
46 return a[i].ID > a[j].ID
47 }
48 return a[i].Size > a[j].Size
49 }
50 func (a ByImageSize) Len() int { return len(a) }
51 func (a ByImageSize) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
52
View as plain text