mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
Kubelet code move: volume / util
This commit is contained in:
@@ -16,6 +16,11 @@ limitations under the License.
|
||||
|
||||
package sliceutils
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
)
|
||||
|
||||
func StringInSlice(s string, list []string) bool {
|
||||
for _, v := range list {
|
||||
if v == s {
|
||||
@@ -25,3 +30,29 @@ func StringInSlice(s string, list []string) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// PodsByCreationTime makes an array of pods sortable by their creation
|
||||
// timestamps in ascending order.
|
||||
type PodsByCreationTime []*api.Pod
|
||||
|
||||
func (s PodsByCreationTime) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s PodsByCreationTime) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
func (s PodsByCreationTime) Less(i, j int) bool {
|
||||
return s[i].CreationTimestamp.Before(s[j].CreationTimestamp)
|
||||
}
|
||||
|
||||
// ByImageSize makes an array of images sortable by their size in descending
|
||||
// order.
|
||||
type ByImageSize []kubecontainer.Image
|
||||
|
||||
func (a ByImageSize) Less(i, j int) bool {
|
||||
return a[i].Size > a[j].Size
|
||||
}
|
||||
func (a ByImageSize) Len() int { return len(a) }
|
||||
func (a ByImageSize) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
|
||||
Reference in New Issue
Block a user