vendor updates

This commit is contained in:
Serguei Bezverkhi
2018-03-06 17:33:18 -05:00
parent 4b3ebc171b
commit e9033989a0
5854 changed files with 248382 additions and 119809 deletions

View File

@ -27,7 +27,6 @@ reviewers:
- ncdc
- tallclair
- eparis
- timothysc
- piosz
- jsafrane
- dims

View File

@ -20,8 +20,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["util_test.go"],
importpath = "k8s.io/kubernetes/pkg/api/v1/endpoints",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",

View File

@ -169,14 +169,6 @@ func LessEndpointAddress(a, b *v1.EndpointAddress) bool {
return a.TargetRef.UID < b.TargetRef.UID
}
type addrPtrsByIpAndUID []*v1.EndpointAddress
func (sl addrPtrsByIpAndUID) Len() int { return len(sl) }
func (sl addrPtrsByIpAndUID) Swap(i, j int) { sl[i], sl[j] = sl[j], sl[i] }
func (sl addrPtrsByIpAndUID) Less(i, j int) bool {
return LessEndpointAddress(sl[i], sl[j])
}
// SortSubsets sorts an array of EndpointSubset objects in place. For ease of
// use it returns the input slice.
func SortSubsets(subsets []v1.EndpointSubset) []v1.EndpointSubset {

View File

@ -20,9 +20,9 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["util_test.go"],
importpath = "k8s.io/kubernetes/pkg/api/v1/pod",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",

View File

@ -238,7 +238,7 @@ func IsPodReady(pod *v1.Pod) bool {
return IsPodReadyConditionTrue(pod.Status)
}
// IsPodReady retruns true if a pod is ready; false otherwise.
// IsPodReady returns true if a pod is ready; false otherwise.
func IsPodReadyConditionTrue(status v1.PodStatus) bool {
condition := GetPodReadyCondition(status)
return condition != nil && condition.Status == v1.ConditionTrue

View File

@ -22,6 +22,7 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
@ -404,3 +405,118 @@ func TestIsPodAvailable(t *testing.T) {
}
}
}
func TestGetContainerStatus(t *testing.T) {
type ExpectedStruct struct {
status v1.ContainerStatus
exists bool
}
tests := []struct {
status []v1.ContainerStatus
name string
expected ExpectedStruct
desc string
}{
{
status: []v1.ContainerStatus{{Name: "test1", Ready: false, Image: "image1"}, {Name: "test2", Ready: true, Image: "image1"}},
name: "test1",
expected: ExpectedStruct{status: v1.ContainerStatus{Name: "test1", Ready: false, Image: "image1"}, exists: true},
desc: "retrieve ContainerStatus with Name=\"test1\"",
},
{
status: []v1.ContainerStatus{{Name: "test2", Ready: false, Image: "image2"}},
name: "test1",
expected: ExpectedStruct{status: v1.ContainerStatus{}, exists: false},
desc: "no matching ContainerStatus with Name=\"test1\"",
},
{
status: []v1.ContainerStatus{{Name: "test3", Ready: false, Image: "image3"}},
name: "",
expected: ExpectedStruct{status: v1.ContainerStatus{}, exists: false},
desc: "retrieve an empty ContainerStatus with container name empty",
},
{
status: nil,
name: "",
expected: ExpectedStruct{status: v1.ContainerStatus{}, exists: false},
desc: "retrieve an empty ContainerStatus with status nil",
},
}
for _, test := range tests {
resultStatus, exists := GetContainerStatus(test.status, test.name)
assert.Equal(t, test.expected.status, resultStatus, "GetContainerStatus: "+test.desc)
assert.Equal(t, test.expected.exists, exists, "GetContainerStatus: "+test.desc)
resultStatus = GetExistingContainerStatus(test.status, test.name)
assert.Equal(t, test.expected.status, resultStatus, "GetExistingContainerStatus: "+test.desc)
}
}
func TestUpdatePodCondition(t *testing.T) {
time := metav1.Now()
podStatus := v1.PodStatus{
Conditions: []v1.PodCondition{
{
Type: v1.PodReady,
Status: v1.ConditionTrue,
Reason: "successfully",
Message: "sync pod successfully",
LastProbeTime: time,
LastTransitionTime: metav1.NewTime(time.Add(1000)),
},
},
}
tests := []struct {
status *v1.PodStatus
conditions v1.PodCondition
expected bool
desc string
}{
{
status: &podStatus,
conditions: v1.PodCondition{
Type: v1.PodReady,
Status: v1.ConditionTrue,
Reason: "successfully",
Message: "sync pod successfully",
LastProbeTime: time,
LastTransitionTime: metav1.NewTime(time.Add(1000))},
expected: false,
desc: "all equal, no update",
},
{
status: &podStatus,
conditions: v1.PodCondition{
Type: v1.PodScheduled,
Status: v1.ConditionTrue,
Reason: "successfully",
Message: "sync pod successfully",
LastProbeTime: time,
LastTransitionTime: metav1.NewTime(time.Add(1000))},
expected: true,
desc: "not equal Type, should get updated",
},
{
status: &podStatus,
conditions: v1.PodCondition{
Type: v1.PodReady,
Status: v1.ConditionFalse,
Reason: "successfully",
Message: "sync pod successfully",
LastProbeTime: time,
LastTransitionTime: metav1.NewTime(time.Add(1000))},
expected: true,
desc: "not equal Status, should get updated",
},
}
for _, test := range tests {
var resultStatus bool
resultStatus = UpdatePodCondition(test.status, &test.conditions)
assert.Equal(t, test.expected, resultStatus, test.desc)
}
}

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["helpers_test.go"],
importpath = "k8s.io/kubernetes/pkg/api/v1/resource",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",

View File

@ -19,8 +19,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["util_test.go"],
importpath = "k8s.io/kubernetes/pkg/api/v1/service",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//pkg/util/net/sets:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",