Bumping k8s dependencies to 1.13

This commit is contained in:
Cheng Xing
2018-11-16 14:08:25 -08:00
parent 305407125c
commit b4c0b68ec7
8002 changed files with 884099 additions and 276228 deletions

View File

@@ -20,7 +20,9 @@ import (
"encoding/json"
"errors"
"fmt"
"reflect"
"sync"
"testing"
"time"
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -38,6 +40,7 @@ import (
"k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/fake"
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api/legacyscheme"
api "k8s.io/kubernetes/pkg/apis/core"
utilnode "k8s.io/kubernetes/pkg/util/node"
@@ -46,6 +49,10 @@ import (
"github.com/golang/glog"
)
var (
keyFunc = cache.DeletionHandlingMetaNamespaceKeyFunc
)
// FakeNodeHandler is a fake implementation of NodesInterface and NodeInterface. It
// allows test cases to have fine-grained control over mock behaviors. We also need
// PodsInterface and PodInterface to test list & delet pods, which is implemented in
@@ -258,7 +265,7 @@ func (m *FakeNodeHandler) UpdateStatus(node *v1.Node) (*v1.Node, error) {
// PatchStatus patches a status of a Node in the fake store.
func (m *FakeNodeHandler) PatchStatus(nodeName string, data []byte) (*v1.Node, error) {
m.RequestCount++
return &v1.Node{}, nil
return m.Patch(nodeName, types.StrategicMergePatchType, data, "status")
}
// Watch watches Nodes in a fake store.
@@ -485,3 +492,27 @@ func GetZones(nodeHandler *FakeNodeHandler) []string {
func CreateZoneID(region, zone string) string {
return region + ":\x00:" + zone
}
// GetKey is a helper function used by controllers unit tests to get the
// key for a given kubernetes resource.
func GetKey(obj interface{}, t *testing.T) string {
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
if ok {
// if tombstone , try getting the value from tombstone.Obj
obj = tombstone.Obj
}
val := reflect.ValueOf(obj).Elem()
name := val.FieldByName("Name").String()
kind := val.FieldByName("Kind").String()
// Note kind is not always set in the tests, so ignoring that for now
if len(name) == 0 || len(kind) == 0 {
t.Errorf("Unexpected object %v", obj)
}
key, err := keyFunc(obj)
if err != nil {
t.Errorf("Unexpected error getting key for %v %v: %v", kind, name, err)
return ""
}
return key
}