-
Notifications
You must be signed in to change notification settings - Fork 4
/
sort.go
66 lines (49 loc) · 1.53 KB
/
sort.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
kubeflowv1 "github.com/StatCan/kubeflow-apis/apis/kubeflow/v1"
corev1 "k8s.io/api/core/v1"
)
// Events by Timestamp
type eventsByTimestamp []*corev1.Event
func (events eventsByTimestamp) Len() int {
return len(events)
}
func (events eventsByTimestamp) Less(a, b int) bool {
return events[b].CreationTimestamp.Before(&events[a].CreationTimestamp)
}
func (events eventsByTimestamp) Swap(a, b int) {
events[a], events[b] = events[b], events[a]
}
// Notebooks by Name
type notebooksByName []*kubeflowv1.Notebook
func (notebooks notebooksByName) Len() int {
return len(notebooks)
}
func (notebooks notebooksByName) Less(a, b int) bool {
return notebooks[a].Name < notebooks[b].Name
}
func (notebooks notebooksByName) Swap(a, b int) {
notebooks[a], notebooks[b] = notebooks[b], notebooks[a]
}
// PersistentVolumeClaims by Name
type persistentVolumeClaimsByName []*corev1.PersistentVolumeClaim
func (pvcs persistentVolumeClaimsByName) Len() int {
return len(pvcs)
}
func (pvcs persistentVolumeClaimsByName) Less(a, b int) bool {
return pvcs[a].Name < pvcs[b].Name
}
func (pvcs persistentVolumeClaimsByName) Swap(a, b int) {
pvcs[a], pvcs[b] = pvcs[b], pvcs[a]
}
// Namespaces by Name
type namespacesByName []*corev1.Namespace
func (namespaces namespacesByName) Len() int {
return len(namespaces)
}
func (namespaces namespacesByName) Less(a, b int) bool {
return namespaces[a].Name < namespaces[b].Name
}
func (namespaces namespacesByName) Swap(a, b int) {
namespaces[a], namespaces[b] = namespaces[b], namespaces[a]
}