Commit 79adb99a authored by Dr. Stefan Schimanski's avatar Dr. Stefan Schimanski Committed by Dr. Stefan Schimanski

pkg/api: move Semantic equality to k8s.io/apimachinery/pkg/api/equality

parent 88d9829a
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"net/http/httputil" "net/http/httputil"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/diff"
...@@ -305,7 +306,7 @@ func TestAPIs(t *testing.T) { ...@@ -305,7 +306,7 @@ func TestAPIs(t *testing.T) {
t.Errorf("%s: %v", tc.name, err) t.Errorf("%s: %v", tc.name, err)
continue continue
} }
if !api.Semantic.DeepEqual(tc.expected, actual) { if !apiequality.Semantic.DeepEqual(tc.expected, actual) {
t.Errorf("%s: %v", tc.name, diff.ObjectDiff(tc.expected, actual)) t.Errorf("%s: %v", tc.name, diff.ObjectDiff(tc.expected, actual))
continue continue
} }
...@@ -467,7 +468,7 @@ func TestAPIGroup(t *testing.T) { ...@@ -467,7 +468,7 @@ func TestAPIGroup(t *testing.T) {
t.Errorf("%s: %v", tc.name, err) t.Errorf("%s: %v", tc.name, err)
continue continue
} }
if !api.Semantic.DeepEqual(tc.expected, actual) { if !apiequality.Semantic.DeepEqual(tc.expected, actual) {
t.Errorf("%s: %v", tc.name, diff.ObjectDiff(tc.expected, actual)) t.Errorf("%s: %v", tc.name, diff.ObjectDiff(tc.expected, actual))
continue continue
} }
......
...@@ -30,6 +30,7 @@ import ( ...@@ -30,6 +30,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -767,7 +768,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image, ...@@ -767,7 +768,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !api.Semantic.DeepEqual(got, namespace) { if !apiequality.Semantic.DeepEqual(got, namespace) {
return nil, fmt.Errorf("Unexpected namespace object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, namespace)) return nil, fmt.Errorf("Unexpected namespace object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, namespace))
} }
return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &namespace)}, nil return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &namespace)}, nil
...@@ -781,7 +782,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image, ...@@ -781,7 +782,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !api.Semantic.DeepEqual(got, svc) { if !apiequality.Semantic.DeepEqual(got, svc) {
return nil, fmt.Errorf("Unexpected service object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, svc)) return nil, fmt.Errorf("Unexpected service object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, svc))
} }
return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &svc)}, nil return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &svc)}, nil
...@@ -812,7 +813,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image, ...@@ -812,7 +813,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
case cmKubeconfigSecretName: case cmKubeconfigSecretName:
want = cmKubeconfigSecret want = cmKubeconfigSecret
} }
if !api.Semantic.DeepEqual(got, want) { if !apiequality.Semantic.DeepEqual(got, want) {
return nil, fmt.Errorf("Unexpected secret object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, want)) return nil, fmt.Errorf("Unexpected secret object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, want))
} }
return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &want)}, nil return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &want)}, nil
...@@ -826,7 +827,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image, ...@@ -826,7 +827,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !api.Semantic.DeepEqual(got, pvc) { if !apiequality.Semantic.DeepEqual(got, pvc) {
return nil, fmt.Errorf("Unexpected PVC object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, pvc)) return nil, fmt.Errorf("Unexpected PVC object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, pvc))
} }
return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &pvc)}, nil return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &pvc)}, nil
...@@ -846,7 +847,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image, ...@@ -846,7 +847,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
case cmName: case cmName:
want = cm want = cm
} }
if !api.Semantic.DeepEqual(got, want) { if !apiequality.Semantic.DeepEqual(got, want) {
return nil, fmt.Errorf("Unexpected deployment object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, want)) return nil, fmt.Errorf("Unexpected deployment object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, want))
} }
return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(extCodec, &want)}, nil return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(extCodec, &want)}, nil
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"net/http" "net/http"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/dynamic" "k8s.io/client-go/dynamic"
...@@ -189,7 +190,7 @@ func testJoinFederationFactory(clusterName, secretName, server string) cmdutil.F ...@@ -189,7 +190,7 @@ func testJoinFederationFactory(clusterName, secretName, server string) cmdutil.F
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !api.Semantic.DeepEqual(got, want) { if !apiequality.Semantic.DeepEqual(got, want) {
return nil, fmt.Errorf("Unexpected cluster object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, want)) return nil, fmt.Errorf("Unexpected cluster object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, want))
} }
return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &want)}, nil return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &want)}, nil
...@@ -265,7 +266,7 @@ func fakeJoinHostFactory(clusterName, clusterCtx, secretName, server, token stri ...@@ -265,7 +266,7 @@ func fakeJoinHostFactory(clusterName, clusterCtx, secretName, server, token stri
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !api.Semantic.DeepEqual(got, secretObject) { if !apiequality.Semantic.DeepEqual(got, secretObject) {
return nil, fmt.Errorf("Unexpected secret object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, secretObject)) return nil, fmt.Errorf("Unexpected secret object\n\tDiff: %s", diff.ObjectGoPrintDiff(got, secretObject))
} }
return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &secretObject)}, nil return &http.Response{StatusCode: http.StatusCreated, Header: kubefedtesting.DefaultHeader(), Body: kubefedtesting.ObjBody(codec, &secretObject)}, nil
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"math/rand" "math/rand"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apitesting "k8s.io/apimachinery/pkg/api/testing" apitesting "k8s.io/apimachinery/pkg/api/testing"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/diff"
...@@ -80,7 +81,7 @@ func BenchmarkNodeConversion(b *testing.B) { ...@@ -80,7 +81,7 @@ func BenchmarkNodeConversion(b *testing.B) {
result = obj.(*api.Node) result = obj.(*api.Node)
} }
b.StopTimer() b.StopTimer()
if !api.Semantic.DeepDerivative(node, *result) { if !apiequality.Semantic.DeepDerivative(node, *result) {
b.Fatalf("Incorrect conversion: %s", diff.ObjectDiff(node, *result)) b.Fatalf("Incorrect conversion: %s", diff.ObjectDiff(node, *result))
} }
} }
...@@ -110,7 +111,7 @@ func BenchmarkReplicationControllerConversion(b *testing.B) { ...@@ -110,7 +111,7 @@ func BenchmarkReplicationControllerConversion(b *testing.B) {
result = obj.(*api.ReplicationController) result = obj.(*api.ReplicationController)
} }
b.StopTimer() b.StopTimer()
if !api.Semantic.DeepDerivative(replicationController, *result) { if !apiequality.Semantic.DeepDerivative(replicationController, *result) {
b.Fatalf("Incorrect conversion: expected %v, got %v", replicationController, *result) b.Fatalf("Incorrect conversion: expected %v, got %v", replicationController, *result)
} }
} }
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
...@@ -140,7 +141,7 @@ func BenchmarkPodCopy(b *testing.B) { ...@@ -140,7 +141,7 @@ func BenchmarkPodCopy(b *testing.B) {
} }
result = obj.(*api.Pod) result = obj.(*api.Pod)
} }
if !api.Semantic.DeepEqual(benchmarkPod, *result) { if !apiequality.Semantic.DeepEqual(benchmarkPod, *result) {
b.Fatalf("Incorrect copy: expected %v, got %v", benchmarkPod, *result) b.Fatalf("Incorrect copy: expected %v, got %v", benchmarkPod, *result)
} }
} }
...@@ -163,7 +164,7 @@ func BenchmarkNodeCopy(b *testing.B) { ...@@ -163,7 +164,7 @@ func BenchmarkNodeCopy(b *testing.B) {
} }
result = obj.(*api.Node) result = obj.(*api.Node)
} }
if !api.Semantic.DeepEqual(node, *result) { if !apiequality.Semantic.DeepEqual(node, *result) {
b.Fatalf("Incorrect copy: expected %v, got %v", node, *result) b.Fatalf("Incorrect copy: expected %v, got %v", node, *result)
} }
} }
...@@ -186,7 +187,7 @@ func BenchmarkReplicationControllerCopy(b *testing.B) { ...@@ -186,7 +187,7 @@ func BenchmarkReplicationControllerCopy(b *testing.B) {
} }
result = obj.(*api.ReplicationController) result = obj.(*api.ReplicationController)
} }
if !api.Semantic.DeepEqual(replicationController, *result) { if !apiequality.Semantic.DeepEqual(replicationController, *result) {
b.Fatalf("Incorrect copy: expected %v, got %v", replicationController, *result) b.Fatalf("Incorrect copy: expected %v, got %v", replicationController, *result)
} }
} }
...@@ -67,7 +67,7 @@ func NonConvertibleFields(annotations map[string]string) map[string]string { ...@@ -67,7 +67,7 @@ func NonConvertibleFields(annotations map[string]string) map[string]string {
} }
// Semantic can do semantic deep equality checks for api objects. // Semantic can do semantic deep equality checks for api objects.
// Example: api.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true // Example: apiequality.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
var Semantic = conversion.EqualitiesOrDie( var Semantic = conversion.EqualitiesOrDie(
func(a, b resource.Quantity) bool { func(a, b resource.Quantity) bool {
// Ignore formatting, only care that numeric value stayed the same. // Ignore formatting, only care that numeric value stayed the same.
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"testing" "testing"
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apitesting "k8s.io/apimachinery/pkg/api/testing" apitesting "k8s.io/apimachinery/pkg/api/testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
...@@ -68,7 +69,7 @@ func TestUniversalDeserializer(t *testing.T) { ...@@ -68,7 +69,7 @@ func TestUniversalDeserializer(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("%s: %v", mediaType, err) t.Fatalf("%s: %v", mediaType, err)
} }
if !api.Semantic.DeepEqual(expected, obj) { if !apiequality.Semantic.DeepEqual(expected, obj) {
t.Fatalf("%s: %#v", mediaType, obj) t.Fatalf("%s: %#v", mediaType, obj)
} }
} }
...@@ -88,7 +89,7 @@ func TestProtobufRoundTrip(t *testing.T) { ...@@ -88,7 +89,7 @@ func TestProtobufRoundTrip(t *testing.T) {
if err := out.Unmarshal(data); err != nil { if err := out.Unmarshal(data); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if !api.Semantic.Equalities.DeepEqual(out, obj) { if !apiequality.Semantic.Equalities.DeepEqual(out, obj) {
t.Logf("marshal\n%s", hex.Dump(data)) t.Logf("marshal\n%s", hex.Dump(data))
t.Fatalf("Unmarshal is unequal\n%s", diff.ObjectGoPrintDiff(out, obj)) t.Fatalf("Unmarshal is unequal\n%s", diff.ObjectGoPrintDiff(out, obj))
} }
......
...@@ -32,6 +32,7 @@ import ( ...@@ -32,6 +32,7 @@ import (
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
"github.com/ugorji/go/codec" "github.com/ugorji/go/codec"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
apitesting "k8s.io/apimachinery/pkg/api/testing" apitesting "k8s.io/apimachinery/pkg/api/testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -321,7 +322,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) { ...@@ -321,7 +322,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
// ensure that the deep copy is equal to the original; neither the deep // ensure that the deep copy is equal to the original; neither the deep
// copy or conversion should alter the object // copy or conversion should alter the object
if !api.Semantic.DeepEqual(original, item) { if !apiequality.Semantic.DeepEqual(original, item) {
t.Errorf("0: %v: encode altered the object, diff: %v", name, diff.ObjectReflectDiff(original, item)) t.Errorf("0: %v: encode altered the object, diff: %v", name, diff.ObjectReflectDiff(original, item))
return return
} }
...@@ -335,7 +336,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) { ...@@ -335,7 +336,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
// ensure that the object produced from decoding the encoded data is equal // ensure that the object produced from decoding the encoded data is equal
// to the original object // to the original object
if !api.Semantic.DeepEqual(original, obj2) { if !apiequality.Semantic.DeepEqual(original, obj2) {
t.Errorf("\n1: %v: diff: %v\nCodec: %#v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, diff.ObjectReflectDiff(item, obj2), codec, printer.Sprintf("%#v", item), dataAsString(data), printer.Sprintf("%#v", obj2)) t.Errorf("\n1: %v: diff: %v\nCodec: %#v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, diff.ObjectReflectDiff(item, obj2), codec, printer.Sprintf("%#v", item), dataAsString(data), printer.Sprintf("%#v", obj2))
return return
} }
...@@ -350,7 +351,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) { ...@@ -350,7 +351,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
// ensure that the new runtime object is equal to the original after being // ensure that the new runtime object is equal to the original after being
// decoded into // decoded into
if !api.Semantic.DeepEqual(item, obj3) { if !apiequality.Semantic.DeepEqual(item, obj3) {
t.Errorf("3: %v: diff: %v\nCodec: %#v", name, diff.ObjectReflectDiff(item, obj3), codec) t.Errorf("3: %v: diff: %v\nCodec: %#v", name, diff.ObjectReflectDiff(item, obj3), codec)
return return
} }
...@@ -383,7 +384,7 @@ func TestEncodePtr(t *testing.T) { ...@@ -383,7 +384,7 @@ func TestEncodePtr(t *testing.T) {
if _, ok := obj2.(*api.Pod); !ok { if _, ok := obj2.(*api.Pod); !ok {
t.Fatalf("Got wrong type") t.Fatalf("Got wrong type")
} }
if !api.Semantic.DeepEqual(obj2, pod) { if !apiequality.Semantic.DeepEqual(obj2, pod) {
t.Errorf("\nExpected:\n\n %#v,\n\nGot:\n\n %#vDiff: %v\n\n", pod, obj2, diff.ObjectDiff(obj2, pod)) t.Errorf("\nExpected:\n\n %#v,\n\nGot:\n\n %#vDiff: %v\n\n", pod, obj2, diff.ObjectDiff(obj2, pod))
} }
} }
...@@ -480,7 +481,7 @@ func TestObjectWatchFraming(t *testing.T) { ...@@ -480,7 +481,7 @@ func TestObjectWatchFraming(t *testing.T) {
} }
resultSecret.Kind = "Secret" resultSecret.Kind = "Secret"
resultSecret.APIVersion = "v1" resultSecret.APIVersion = "v1"
if !api.Semantic.DeepEqual(v1secret, res) { if !apiequality.Semantic.DeepEqual(v1secret, res) {
t.Fatalf("objects did not match: %s", diff.ObjectGoPrintDiff(v1secret, res)) t.Fatalf("objects did not match: %s", diff.ObjectGoPrintDiff(v1secret, res))
} }
...@@ -514,7 +515,7 @@ func TestObjectWatchFraming(t *testing.T) { ...@@ -514,7 +515,7 @@ func TestObjectWatchFraming(t *testing.T) {
} }
} }
if !api.Semantic.DeepEqual(secret, outEvent.Object.Object) { if !apiequality.Semantic.DeepEqual(secret, outEvent.Object.Object) {
t.Fatalf("%s: did not match after frame decoding: %s", info.MediaType, diff.ObjectGoPrintDiff(secret, outEvent.Object.Object)) t.Fatalf("%s: did not match after frame decoding: %s", info.MediaType, diff.ObjectGoPrintDiff(secret, outEvent.Object.Object))
} }
} }
......
...@@ -21,7 +21,7 @@ import ( ...@@ -21,7 +21,7 @@ import (
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
) )
// DeepEqualSafePodSpec returns a PodSpec which is ready to be used with api.Semantic.DeepEqual // DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual
func DeepEqualSafePodSpec() api.PodSpec { func DeepEqualSafePodSpec() api.PodSpec {
grace := int64(30) grace := int64(30)
return api.PodSpec{ return api.PodSpec{
...@@ -33,7 +33,7 @@ func DeepEqualSafePodSpec() api.PodSpec { ...@@ -33,7 +33,7 @@ func DeepEqualSafePodSpec() api.PodSpec {
} }
} }
// V1DeepEqualSafePodSpec returns a PodSpec which is ready to be used with api.Semantic.DeepEqual // V1DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual
func V1DeepEqualSafePodSpec() v1.PodSpec { func V1DeepEqualSafePodSpec() v1.PodSpec {
grace := int64(30) grace := int64(30)
return v1.PodSpec{ return v1.PodSpec{
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"reflect" "reflect"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apitesting "k8s.io/apimachinery/pkg/api/testing" apitesting "k8s.io/apimachinery/pkg/api/testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi" "k8s.io/kubernetes/pkg/api/testapi"
...@@ -89,7 +90,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) { ...@@ -89,7 +90,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) {
t.Errorf("Error when unmarshaling to object: %v", err) t.Errorf("Error when unmarshaling to object: %v", err)
return return
} }
if !api.Semantic.DeepEqual(item, unmarshalledObj) { if !apiequality.Semantic.DeepEqual(item, unmarshalledObj) {
t.Errorf("Object changed during JSON operations, diff: %v", diff.ObjectReflectDiff(item, unmarshalledObj)) t.Errorf("Object changed during JSON operations, diff: %v", diff.ObjectReflectDiff(item, unmarshalledObj))
return return
} }
...@@ -111,7 +112,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) { ...@@ -111,7 +112,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) {
return return
} }
if !api.Semantic.DeepEqual(item, newObj) { if !apiequality.Semantic.DeepEqual(item, newObj) {
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(item, newObj)) t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(item, newObj))
} }
*/ */
......
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
...@@ -210,7 +211,7 @@ func TestResourceListConversion(t *testing.T) { ...@@ -210,7 +211,7 @@ func TestResourceListConversion(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("unexpected error for case %d: %v", i, err) t.Fatalf("unexpected error for case %d: %v", i, err)
} }
if !api.Semantic.DeepEqual(test.expected, output) { if !apiequality.Semantic.DeepEqual(test.expected, output) {
t.Errorf("unexpected conversion for case %d: Expected %+v; Got %+v", i, test.expected, output) t.Errorf("unexpected conversion for case %d: Expected %+v; Got %+v", i, test.expected, output)
} }
} }
......
...@@ -20,9 +20,9 @@ import ( ...@@ -20,9 +20,9 @@ import (
"reflect" "reflect"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/kubernetes/pkg/api"
) )
func TestAddToNodeAddresses(t *testing.T) { func TestAddToNodeAddresses(t *testing.T) {
...@@ -76,7 +76,7 @@ func TestAddToNodeAddresses(t *testing.T) { ...@@ -76,7 +76,7 @@ func TestAddToNodeAddresses(t *testing.T) {
for i, tc := range testCases { for i, tc := range testCases {
AddToNodeAddresses(&tc.existing, tc.toAdd...) AddToNodeAddresses(&tc.existing, tc.toAdd...)
if !api.Semantic.DeepEqual(tc.expected, tc.existing) { if !apiequality.Semantic.DeepEqual(tc.expected, tc.existing) {
t.Errorf("case[%d], expected: %v, got: %v", i, tc.expected, tc.existing) t.Errorf("case[%d], expected: %v, got: %v", i, tc.expected, tc.existing)
} }
} }
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"strings" "strings"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apimachineyvalidation "k8s.io/apimachinery/pkg/api/validation" apimachineyvalidation "k8s.io/apimachinery/pkg/api/validation"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1validation "k8s.io/apimachinery/pkg/apis/meta/v1/validation" v1validation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
...@@ -133,7 +134,7 @@ func ValidateNoNewFinalizers(newFinalizers []string, oldFinalizers []string, fld ...@@ -133,7 +134,7 @@ func ValidateNoNewFinalizers(newFinalizers []string, oldFinalizers []string, fld
func ValidateImmutableField(newVal, oldVal interface{}, fldPath *field.Path) field.ErrorList { func ValidateImmutableField(newVal, oldVal interface{}, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{} allErrs := field.ErrorList{}
if !api.Semantic.DeepEqual(oldVal, newVal) { if !apiequality.Semantic.DeepEqual(oldVal, newVal) {
allErrs = append(allErrs, field.Invalid(fldPath, newVal, FieldImmutableErrorMsg)) allErrs = append(allErrs, field.Invalid(fldPath, newVal, FieldImmutableErrorMsg))
} }
return allErrs return allErrs
......
...@@ -28,6 +28,7 @@ import ( ...@@ -28,6 +28,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation" apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -1092,7 +1093,7 @@ func ValidatePersistentVolumeClaimUpdate(newPvc, oldPvc *api.PersistentVolumeCla ...@@ -1092,7 +1093,7 @@ func ValidatePersistentVolumeClaimUpdate(newPvc, oldPvc *api.PersistentVolumeCla
} }
// changes to Spec are not allowed, but updates to label/and some annotations are OK. // changes to Spec are not allowed, but updates to label/and some annotations are OK.
// no-op updates pass validation. // no-op updates pass validation.
if !api.Semantic.DeepEqual(newPvc.Spec, oldPvc.Spec) { if !apiequality.Semantic.DeepEqual(newPvc.Spec, oldPvc.Spec) {
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "field is immutable after creation")) allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "field is immutable after creation"))
} }
...@@ -2253,7 +2254,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList { ...@@ -2253,7 +2254,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
activeDeadlineSeconds := *oldPod.Spec.ActiveDeadlineSeconds activeDeadlineSeconds := *oldPod.Spec.ActiveDeadlineSeconds
mungedPod.Spec.ActiveDeadlineSeconds = &activeDeadlineSeconds mungedPod.Spec.ActiveDeadlineSeconds = &activeDeadlineSeconds
} }
if !api.Semantic.DeepEqual(mungedPod.Spec, oldPod.Spec) { if !apiequality.Semantic.DeepEqual(mungedPod.Spec, oldPod.Spec) {
//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff //TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
allErrs = append(allErrs, field.Forbidden(specPath, "pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`")) allErrs = append(allErrs, field.Forbidden(specPath, "pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`"))
} }
...@@ -2789,7 +2790,7 @@ func ValidateNodeUpdate(node, oldNode *api.Node) field.ErrorList { ...@@ -2789,7 +2790,7 @@ func ValidateNodeUpdate(node, oldNode *api.Node) field.ErrorList {
// TODO: Enable the code once we have better api object.status update model. Currently, // TODO: Enable the code once we have better api object.status update model. Currently,
// anyone can update node status. // anyone can update node status.
// if !api.Semantic.DeepEqual(node.Status, api.NodeStatus{}) { // if !apiequality.Semantic.DeepEqual(node.Status, api.NodeStatus{}) {
// allErrs = append(allErrs, field.Invalid("status", node.Status, "must be empty")) // allErrs = append(allErrs, field.Invalid("status", node.Status, "must be empty"))
// } // }
...@@ -2832,7 +2833,7 @@ func ValidateNodeUpdate(node, oldNode *api.Node) field.ErrorList { ...@@ -2832,7 +2833,7 @@ func ValidateNodeUpdate(node, oldNode *api.Node) field.ErrorList {
oldNode.Status = node.Status oldNode.Status = node.Status
// TODO: Add a 'real' error type for this error and provide print actual diffs. // TODO: Add a 'real' error type for this error and provide print actual diffs.
if !api.Semantic.DeepEqual(oldNode, node) { if !apiequality.Semantic.DeepEqual(oldNode, node) {
glog.V(4).Infof("Update failed validation %#v vs %#v", oldNode, node) glog.V(4).Infof("Update failed validation %#v vs %#v", oldNode, node)
allErrs = append(allErrs, field.Forbidden(field.NewPath(""), "node updates may only change labels or capacity")) allErrs = append(allErrs, field.Forbidden(field.NewPath(""), "node updates may only change labels or capacity"))
} }
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"strings" "strings"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
...@@ -344,7 +345,7 @@ func TestDecodeObjects(t *testing.T) { ...@@ -344,7 +345,7 @@ func TestDecodeObjects(t *testing.T) {
continue continue
} }
if !api.Semantic.DeepEqual(obj, test.obj) { if !apiequality.Semantic.DeepEqual(obj, test.obj) {
t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintDiff(test.obj, obj)) t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintDiff(test.obj, obj))
continue continue
} }
......
...@@ -17,9 +17,9 @@ limitations under the License. ...@@ -17,9 +17,9 @@ limitations under the License.
package validation package validation
import ( import (
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
) )
...@@ -52,7 +52,7 @@ func ValidateSelfSubjectAccessReviewSpec(spec authorizationapi.SelfSubjectAccess ...@@ -52,7 +52,7 @@ func ValidateSelfSubjectAccessReviewSpec(spec authorizationapi.SelfSubjectAccess
func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) field.ErrorList { func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) field.ErrorList {
allErrs := ValidateSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) allErrs := ValidateSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec"))
if !api.Semantic.DeepEqual(metav1.ObjectMeta{}, sar.ObjectMeta) { if !apiequality.Semantic.DeepEqual(metav1.ObjectMeta{}, sar.ObjectMeta) {
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty`)) allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty`))
} }
return allErrs return allErrs
...@@ -60,7 +60,7 @@ func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) fiel ...@@ -60,7 +60,7 @@ func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) fiel
func ValidateSelfSubjectAccessReview(sar *authorizationapi.SelfSubjectAccessReview) field.ErrorList { func ValidateSelfSubjectAccessReview(sar *authorizationapi.SelfSubjectAccessReview) field.ErrorList {
allErrs := ValidateSelfSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) allErrs := ValidateSelfSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec"))
if !api.Semantic.DeepEqual(metav1.ObjectMeta{}, sar.ObjectMeta) { if !apiequality.Semantic.DeepEqual(metav1.ObjectMeta{}, sar.ObjectMeta) {
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty`)) allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty`))
} }
return allErrs return allErrs
...@@ -71,7 +71,7 @@ func ValidateLocalSubjectAccessReview(sar *authorizationapi.LocalSubjectAccessRe ...@@ -71,7 +71,7 @@ func ValidateLocalSubjectAccessReview(sar *authorizationapi.LocalSubjectAccessRe
objectMetaShallowCopy := sar.ObjectMeta objectMetaShallowCopy := sar.ObjectMeta
objectMetaShallowCopy.Namespace = "" objectMetaShallowCopy.Namespace = ""
if !api.Semantic.DeepEqual(metav1.ObjectMeta{}, objectMetaShallowCopy) { if !apiequality.Semantic.DeepEqual(metav1.ObjectMeta{}, objectMetaShallowCopy) {
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty except for namespace`)) allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty except for namespace`))
} }
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"strings" "strings"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
...@@ -99,7 +100,7 @@ func (c *Client) ServerURL() string { ...@@ -99,7 +100,7 @@ func (c *Client) ServerURL() string {
func (c *Client) Validate(t *testing.T, received runtime.Object, err error) { func (c *Client) Validate(t *testing.T, received runtime.Object, err error) {
c.ValidateCommon(t, err) c.ValidateCommon(t, err)
if c.Response.Body != nil && !api.Semantic.DeepDerivative(c.Response.Body, received) { if c.Response.Body != nil && !apiequality.Semantic.DeepDerivative(c.Response.Body, received) {
t.Errorf("bad response for request %#v: \nexpected %#v\ngot %#v\n", c.Request, c.Response.Body, received) t.Errorf("bad response for request %#v: \nexpected %#v\ngot %#v\n", c.Request, c.Response.Body, received)
} }
} }
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
...@@ -273,7 +274,7 @@ func TestCreatePods(t *testing.T) { ...@@ -273,7 +274,7 @@ func TestCreatePods(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }
if !api.Semantic.DeepDerivative(&expectedPod, actualPod) { if !apiequality.Semantic.DeepDerivative(&expectedPod, actualPod) {
t.Logf("Body: %s", fakeHandler.RequestBody) t.Logf("Body: %s", fakeHandler.RequestBody)
t.Errorf("Unexpected mismatch. Expected\n %#v,\n Got:\n %#v", &expectedPod, actualPod) t.Errorf("Unexpected mismatch. Expected\n %#v,\n Got:\n %#v", &expectedPod, actualPod)
} }
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
...@@ -35,7 +36,6 @@ import ( ...@@ -35,7 +36,6 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
...@@ -285,7 +285,7 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) { ...@@ -285,7 +285,7 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) {
} }
// A number of things could affect the old deployment: labels changing, // A number of things could affect the old deployment: labels changing,
// pod template changing, etc. // pod template changing, etc.
if !api.Semantic.DeepEqual(oldRS, curRS) { if !apiequality.Semantic.DeepEqual(oldRS, curRS) {
if oldD := dc.getDeploymentForReplicaSet(oldRS); oldD != nil { if oldD := dc.getDeploymentForReplicaSet(oldRS); oldD != nil {
dc.enqueueDeployment(oldD) dc.enqueueDeployment(oldD)
} }
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
...@@ -605,7 +606,7 @@ func EqualIgnoreHash(template1, template2 v1.PodTemplateSpec) bool { ...@@ -605,7 +606,7 @@ func EqualIgnoreHash(template1, template2 v1.PodTemplateSpec) bool {
} }
// Then, compare the templates without comparing their labels // Then, compare the templates without comparing their labels
template1.Labels, template2.Labels = nil, nil template1.Labels, template2.Labels = nil, nil
return api.Semantic.DeepEqual(template1, template2) return apiequality.Semantic.DeepEqual(template1, template2)
} }
// FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template). // FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template).
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
core "k8s.io/client-go/testing" core "k8s.io/client-go/testing"
...@@ -256,7 +257,7 @@ func TestGetNewRC(t *testing.T) { ...@@ -256,7 +257,7 @@ func TestGetNewRC(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("In test case %s, got unexpected error %v", test.test, err) t.Errorf("In test case %s, got unexpected error %v", test.test, err)
} }
if !api.Semantic.DeepEqual(rs, test.expected) { if !apiequality.Semantic.DeepEqual(rs, test.expected) {
t.Errorf("In test case %s, expected %#v, got %#v", test.test, test.expected, rs) t.Errorf("In test case %s, expected %#v, got %#v", test.test, test.expected, rs)
} }
} }
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand" "k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
...@@ -656,7 +657,7 @@ func TestWatchJobs(t *testing.T) { ...@@ -656,7 +657,7 @@ func TestWatchJobs(t *testing.T) {
t.Errorf("Expected to find job under key %v: %v", key, err) t.Errorf("Expected to find job under key %v: %v", key, err)
return nil return nil
} }
if !api.Semantic.DeepDerivative(*job, testJob) { if !apiequality.Semantic.DeepDerivative(*job, testJob) {
t.Errorf("Expected %#v, but got %#v", testJob, *job) t.Errorf("Expected %#v, but got %#v", testJob, *job)
} }
return nil return nil
...@@ -699,7 +700,7 @@ func TestWatchPods(t *testing.T) { ...@@ -699,7 +700,7 @@ func TestWatchPods(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("Expected to find job under key %v: %v", key, err) t.Errorf("Expected to find job under key %v: %v", key, err)
} }
if !api.Semantic.DeepDerivative(job, testJob) { if !apiequality.Semantic.DeepDerivative(job, testJob) {
t.Errorf("\nExpected %#v,\nbut got %#v", testJob, job) t.Errorf("\nExpected %#v,\nbut got %#v", testJob, job)
close(received) close(received)
return nil return nil
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
...@@ -777,7 +778,7 @@ func (nc *NodeController) tryUpdateNodeStatus(node *v1.Node) (time.Duration, v1. ...@@ -777,7 +778,7 @@ func (nc *NodeController) tryUpdateNodeStatus(node *v1.Node) (time.Duration, v1.
} }
_, currentCondition := v1.GetNodeCondition(&node.Status, v1.NodeReady) _, currentCondition := v1.GetNodeCondition(&node.Status, v1.NodeReady)
if !api.Semantic.DeepEqual(currentCondition, &observedReadyCondition) { if !apiequality.Semantic.DeepEqual(currentCondition, &observedReadyCondition) {
if _, err = nc.kubeClient.Core().Nodes().UpdateStatus(node); err != nil { if _, err = nc.kubeClient.Core().Nodes().UpdateStatus(node); err != nil {
glog.Errorf("Error updating node %s: %v", node.Name, err) glog.Errorf("Error updating node %s: %v", node.Name, err)
return gracePeriod, observedReadyCondition, currentReadyCondition, err return gracePeriod, observedReadyCondition, currentReadyCondition, err
......
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
...@@ -29,7 +30,6 @@ import ( ...@@ -29,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
testcore "k8s.io/client-go/testing" testcore "k8s.io/client-go/testing"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
...@@ -1524,10 +1524,10 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) { ...@@ -1524,10 +1524,10 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
if item.expectedRequestCount != item.fakeNodeHandler.RequestCount { if item.expectedRequestCount != item.fakeNodeHandler.RequestCount {
t.Errorf("expected %v call, but got %v.", item.expectedRequestCount, item.fakeNodeHandler.RequestCount) t.Errorf("expected %v call, but got %v.", item.expectedRequestCount, item.fakeNodeHandler.RequestCount)
} }
if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !api.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) { if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) {
t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0])) t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
} }
if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !api.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) { if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) {
t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0])) t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
} }
} }
......
...@@ -28,6 +28,7 @@ import ( ...@@ -28,6 +28,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
...@@ -541,7 +542,7 @@ func TestWatchControllers(t *testing.T) { ...@@ -541,7 +542,7 @@ func TestWatchControllers(t *testing.T) {
t.Errorf("Expected to find replica set under key %v", key) t.Errorf("Expected to find replica set under key %v", key)
} }
rsSpec := *obj.(*extensions.ReplicaSet) rsSpec := *obj.(*extensions.ReplicaSet)
if !api.Semantic.DeepDerivative(rsSpec, testRSSpec) { if !apiequality.Semantic.DeepDerivative(rsSpec, testRSSpec) {
t.Errorf("Expected %#v, but got %#v", testRSSpec, rsSpec) t.Errorf("Expected %#v, but got %#v", testRSSpec, rsSpec)
} }
close(received) close(received)
...@@ -583,7 +584,7 @@ func TestWatchPods(t *testing.T) { ...@@ -583,7 +584,7 @@ func TestWatchPods(t *testing.T) {
t.Errorf("Expected to find replica set under key %v", key) t.Errorf("Expected to find replica set under key %v", key)
} }
rsSpec := obj.(*extensions.ReplicaSet) rsSpec := obj.(*extensions.ReplicaSet)
if !api.Semantic.DeepDerivative(rsSpec, testRSSpec) { if !apiequality.Semantic.DeepDerivative(rsSpec, testRSSpec) {
t.Errorf("\nExpected %#v,\nbut got %#v", testRSSpec, rsSpec) t.Errorf("\nExpected %#v,\nbut got %#v", testRSSpec, rsSpec)
} }
close(received) close(received)
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
...@@ -471,7 +472,7 @@ func TestWatchControllers(t *testing.T) { ...@@ -471,7 +472,7 @@ func TestWatchControllers(t *testing.T) {
t.Errorf("Expected to find controller under key %v", key) t.Errorf("Expected to find controller under key %v", key)
} }
controllerSpec := *obj.(*v1.ReplicationController) controllerSpec := *obj.(*v1.ReplicationController)
if !api.Semantic.DeepDerivative(controllerSpec, testControllerSpec) { if !apiequality.Semantic.DeepDerivative(controllerSpec, testControllerSpec) {
t.Errorf("Expected %#v, but got %#v", testControllerSpec, controllerSpec) t.Errorf("Expected %#v, but got %#v", testControllerSpec, controllerSpec)
} }
close(received) close(received)
...@@ -512,7 +513,7 @@ func TestWatchPods(t *testing.T) { ...@@ -512,7 +513,7 @@ func TestWatchPods(t *testing.T) {
t.Errorf("Expected to find controller under key %v", key) t.Errorf("Expected to find controller under key %v", key)
} }
controllerSpec := obj.(*v1.ReplicationController) controllerSpec := obj.(*v1.ReplicationController)
if !api.Semantic.DeepDerivative(controllerSpec, testControllerSpec) { if !apiequality.Semantic.DeepDerivative(controllerSpec, testControllerSpec) {
t.Errorf("\nExpected %#v,\nbut got %#v", testControllerSpec, controllerSpec) t.Errorf("\nExpected %#v,\nbut got %#v", testControllerSpec, controllerSpec)
} }
close(received) close(received)
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
...@@ -174,7 +175,7 @@ func (rq *ResourceQuotaController) addQuota(obj interface{}) { ...@@ -174,7 +175,7 @@ func (rq *ResourceQuotaController) addQuota(obj interface{}) {
resourceQuota := obj.(*v1.ResourceQuota) resourceQuota := obj.(*v1.ResourceQuota)
// if we declared an intent that is not yet captured in status (prioritize it) // if we declared an intent that is not yet captured in status (prioritize it)
if !api.Semantic.DeepEqual(resourceQuota.Spec.Hard, resourceQuota.Status.Hard) { if !apiequality.Semantic.DeepEqual(resourceQuota.Spec.Hard, resourceQuota.Status.Hard) {
rq.missingUsageQueue.Add(key) rq.missingUsageQueue.Add(key)
return return
} }
...@@ -268,7 +269,7 @@ func (rq *ResourceQuotaController) syncResourceQuotaFromKey(key string) (err err ...@@ -268,7 +269,7 @@ func (rq *ResourceQuotaController) syncResourceQuotaFromKey(key string) (err err
// syncResourceQuota runs a complete sync of resource quota status across all known kinds // syncResourceQuota runs a complete sync of resource quota status across all known kinds
func (rq *ResourceQuotaController) syncResourceQuota(v1ResourceQuota v1.ResourceQuota) (err error) { func (rq *ResourceQuotaController) syncResourceQuota(v1ResourceQuota v1.ResourceQuota) (err error) {
// quota is dirty if any part of spec hard limits differs from the status hard limits // quota is dirty if any part of spec hard limits differs from the status hard limits
dirty := !api.Semantic.DeepEqual(v1ResourceQuota.Spec.Hard, v1ResourceQuota.Status.Hard) dirty := !apiequality.Semantic.DeepEqual(v1ResourceQuota.Spec.Hard, v1ResourceQuota.Status.Hard)
resourceQuota := api.ResourceQuota{} resourceQuota := api.ResourceQuota{}
if err := v1.Convert_v1_ResourceQuota_To_api_ResourceQuota(&v1ResourceQuota, &resourceQuota, nil); err != nil { if err := v1.Convert_v1_ResourceQuota_To_api_ResourceQuota(&v1ResourceQuota, &resourceQuota, nil); err != nil {
......
...@@ -34,6 +34,9 @@ import ( ...@@ -34,6 +34,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/emicklei/go-restful"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apierrs "k8s.io/apimachinery/pkg/api/errors" apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
apitesting "k8s.io/apimachinery/pkg/api/testing" apitesting "k8s.io/apimachinery/pkg/api/testing"
...@@ -57,8 +60,6 @@ import ( ...@@ -57,8 +60,6 @@ import (
"k8s.io/kubernetes/pkg/genericapiserver/registry/rest" "k8s.io/kubernetes/pkg/genericapiserver/registry/rest"
"k8s.io/kubernetes/plugin/pkg/admission/admit" "k8s.io/kubernetes/plugin/pkg/admission/admit"
"k8s.io/kubernetes/plugin/pkg/admission/deny" "k8s.io/kubernetes/plugin/pkg/admission/deny"
"github.com/emicklei/go-restful"
) )
// This creates fake API versions, similar to api/latest.go. // This creates fake API versions, similar to api/latest.go.
...@@ -1739,7 +1740,7 @@ func TestConnectResponderObject(t *testing.T) { ...@@ -1739,7 +1740,7 @@ func TestConnectResponderObject(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if !api.Semantic.DeepEqual(obj, simple) { if !apiequality.Semantic.DeepEqual(obj, simple) {
t.Errorf("Unexpected response: %#v", obj) t.Errorf("Unexpected response: %#v", obj)
} }
} }
...@@ -1969,7 +1970,7 @@ func TestDeleteWithOptions(t *testing.T) { ...@@ -1969,7 +1970,7 @@ func TestDeleteWithOptions(t *testing.T) {
t.Errorf("Unexpected delete: %s, expected %s", simpleStorage.deleted, ID) t.Errorf("Unexpected delete: %s, expected %s", simpleStorage.deleted, ID)
} }
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{}) simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
if !api.Semantic.DeepEqual(simpleStorage.deleteOptions, item) { if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item)) t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item))
} }
} }
...@@ -2006,7 +2007,7 @@ func TestDeleteWithOptionsQuery(t *testing.T) { ...@@ -2006,7 +2007,7 @@ func TestDeleteWithOptionsQuery(t *testing.T) {
t.Fatalf("Unexpected delete: %s, expected %s", simpleStorage.deleted, ID) t.Fatalf("Unexpected delete: %s, expected %s", simpleStorage.deleted, ID)
} }
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{}) simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
if !api.Semantic.DeepEqual(simpleStorage.deleteOptions, item) { if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item)) t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item))
} }
} }
...@@ -2046,7 +2047,7 @@ func TestDeleteWithOptionsQueryAndBody(t *testing.T) { ...@@ -2046,7 +2047,7 @@ func TestDeleteWithOptionsQueryAndBody(t *testing.T) {
t.Errorf("Unexpected delete: %s, expected %s", simpleStorage.deleted, ID) t.Errorf("Unexpected delete: %s, expected %s", simpleStorage.deleted, ID)
} }
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{}) simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
if !api.Semantic.DeepEqual(simpleStorage.deleteOptions, item) { if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item)) t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item))
} }
} }
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"github.com/emicklei/go-restful" "github.com/emicklei/go-restful"
"github.com/evanphx/json-patch" "github.com/evanphx/json-patch"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
...@@ -74,7 +75,7 @@ func TestPatchAnonymousField(t *testing.T) { ...@@ -74,7 +75,7 @@ func TestPatchAnonymousField(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
if !api.Semantic.DeepEqual(actual, expected) { if !apiequality.Semantic.DeepEqual(actual, expected) {
t.Errorf("expected %#v, got %#v", expected, actual) t.Errorf("expected %#v, got %#v", expected, actual)
} }
} }
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
...@@ -204,7 +205,7 @@ func TestStoreList(t *testing.T) { ...@@ -204,7 +205,7 @@ func TestStoreList(t *testing.T) {
} }
// DeepDerivative e,a is needed here b/c the storage layer sets ResourceVersion // DeepDerivative e,a is needed here b/c the storage layer sets ResourceVersion
if e, a := item.out, list; !api.Semantic.DeepDerivative(e, a) { if e, a := item.out, list; !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("%v: Expected %#v, got %#v", name, e, a) t.Errorf("%v: Expected %#v, got %#v", name, e, a)
} }
destroyFunc() destroyFunc()
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/validation/path" "k8s.io/apimachinery/pkg/api/validation/path"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
...@@ -276,7 +277,7 @@ func (t *Tester) testCreateEquals(obj runtime.Object, getFn GetFunc) { ...@@ -276,7 +277,7 @@ func (t *Tester) testCreateEquals(obj runtime.Object, getFn GetFunc) {
gotMeta := t.getObjectMetaOrFail(got) gotMeta := t.getObjectMetaOrFail(got)
createdMeta.ResourceVersion = gotMeta.ResourceVersion createdMeta.ResourceVersion = gotMeta.ResourceVersion
if e, a := created, got; !api.Semantic.DeepEqual(e, a) { if e, a := created, got; !apiequality.Semantic.DeepEqual(e, a) {
t.Errorf("unexpected obj: %#v, expected %#v", e, a) t.Errorf("unexpected obj: %#v, expected %#v", e, a)
} }
} }
...@@ -484,7 +485,7 @@ func (t *Tester) testUpdateEquals(obj runtime.Object, createFn CreateFunc, getFn ...@@ -484,7 +485,7 @@ func (t *Tester) testUpdateEquals(obj runtime.Object, createFn CreateFunc, getFn
gotMeta := t.getObjectMetaOrFail(got) gotMeta := t.getObjectMetaOrFail(got)
updatedMeta.ResourceVersion = gotMeta.ResourceVersion updatedMeta.ResourceVersion = gotMeta.ResourceVersion
if e, a := updated, got; !api.Semantic.DeepEqual(e, a) { if e, a := updated, got; !apiequality.Semantic.DeepEqual(e, a) {
t.Errorf("unexpected obj: %#v, expected %#v", e, a) t.Errorf("unexpected obj: %#v, expected %#v", e, a)
} }
} }
...@@ -1091,7 +1092,7 @@ func (t *Tester) testGetFound(obj runtime.Object) { ...@@ -1091,7 +1092,7 @@ func (t *Tester) testGetFound(obj runtime.Object) {
} }
gotMeta := t.getObjectMetaOrFail(got) gotMeta := t.getObjectMetaOrFail(got)
gotMeta.ResourceVersion = existingMeta.ResourceVersion gotMeta.ResourceVersion = existingMeta.ResourceVersion
if e, a := existing, got; !api.Semantic.DeepEqual(e, a) { if e, a := existing, got; !apiequality.Semantic.DeepEqual(e, a) {
t.Errorf("unexpected obj: %#v, expected %#v", e, a) t.Errorf("unexpected obj: %#v, expected %#v", e, a)
} }
} }
...@@ -1174,7 +1175,7 @@ func (t *Tester) testListFound(obj runtime.Object, assignFn AssignFunc) { ...@@ -1174,7 +1175,7 @@ func (t *Tester) testListFound(obj runtime.Object, assignFn AssignFunc) {
if len(items) != len(existing) { if len(items) != len(existing) {
t.Errorf("unexpected number of items: %v", len(items)) t.Errorf("unexpected number of items: %v", len(items))
} }
if !api.Semantic.DeepEqual(existing, items) { if !apiequality.Semantic.DeepEqual(existing, items) {
t.Errorf("expected: %#v, got: %#v", existing, items) t.Errorf("expected: %#v, got: %#v", existing, items)
} }
} }
...@@ -1209,7 +1210,7 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) { ...@@ -1209,7 +1210,7 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
if len(items) != len(filtered) { if len(items) != len(filtered) {
t.Errorf("unexpected number of items: %v", len(items)) t.Errorf("unexpected number of items: %v", len(items))
} }
if !api.Semantic.DeepEqual(filtered, items) { if !apiequality.Semantic.DeepEqual(filtered, items) {
t.Errorf("expected: %#v, got: %#v", filtered, items) t.Errorf("expected: %#v, got: %#v", filtered, items)
} }
} }
......
...@@ -26,10 +26,10 @@ import ( ...@@ -26,10 +26,10 @@ import (
"strings" "strings"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api" clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"k8s.io/kubernetes/pkg/api"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
) )
...@@ -897,7 +897,7 @@ func (test configCommandTest) run(t *testing.T) string { ...@@ -897,7 +897,7 @@ func (test configCommandTest) run(t *testing.T) string {
testSetNilMapsToEmpties(reflect.ValueOf(&actualConfig)) testSetNilMapsToEmpties(reflect.ValueOf(&actualConfig))
testClearLocationOfOrigin(&actualConfig) testClearLocationOfOrigin(&actualConfig)
if !api.Semantic.DeepEqual(test.expectedConfig, actualConfig) { if !apiequality.Semantic.DeepEqual(test.expectedConfig, actualConfig) {
t.Errorf("diff: %v", diff.ObjectDiff(test.expectedConfig, actualConfig)) t.Errorf("diff: %v", diff.ObjectDiff(test.expectedConfig, actualConfig))
t.Errorf("expected: %#v\n actual: %#v", test.expectedConfig, actualConfig) t.Errorf("expected: %#v\n actual: %#v", test.expectedConfig, actualConfig)
} }
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"strings" "strings"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
...@@ -280,7 +281,7 @@ func verifyObjects(t *testing.T, expected, actual []runtime.Object) { ...@@ -280,7 +281,7 @@ func verifyObjects(t *testing.T, expected, actual []runtime.Object) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if !api.Semantic.DeepEqual(expected[i], actualObj) { if !apiequality.Semantic.DeepEqual(expected[i], actualObj) {
t.Errorf("unexpected object: \n%#v\n%#v", expected[i], actualObj) t.Errorf("unexpected object: \n%#v\n%#v", expected[i], actualObj)
} }
} }
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/federation/apis/federation" "k8s.io/kubernetes/federation/apis/federation"
...@@ -563,7 +564,7 @@ func TestGetPodsTotalRequests(t *testing.T) { ...@@ -563,7 +564,7 @@ func TestGetPodsTotalRequests(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("Unexpected error %v", err) t.Errorf("Unexpected error %v", err)
} }
if !api.Semantic.DeepEqual(reqs, testCase.expectedReqs) { if !apiequality.Semantic.DeepEqual(reqs, testCase.expectedReqs) {
t.Errorf("Expected %v, got %v", testCase.expectedReqs, reqs) t.Errorf("Expected %v, got %v", testCase.expectedReqs, reqs)
} }
} }
......
...@@ -31,6 +31,7 @@ import ( ...@@ -31,6 +31,7 @@ import (
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -591,7 +592,7 @@ func TestMultipleResourceByTheSameName(t *testing.T) { ...@@ -591,7 +592,7 @@ func TestMultipleResourceByTheSameName(t *testing.T) {
if err != nil || singleItemImplied || len(test.Infos) != 4 { if err != nil || singleItemImplied || len(test.Infos) != 4 {
t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos) t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos)
} }
if !api.Semantic.DeepDerivative([]runtime.Object{&pods.Items[0], &pods.Items[1], &svcs.Items[0], &svcs.Items[0]}, test.Objects()) { if !apiequality.Semantic.DeepDerivative([]runtime.Object{&pods.Items[0], &pods.Items[1], &svcs.Items[0], &svcs.Items[0]}, test.Objects()) {
t.Errorf("unexpected visited objects: %#v", test.Objects()) t.Errorf("unexpected visited objects: %#v", test.Objects())
} }
...@@ -734,7 +735,7 @@ func TestSelector(t *testing.T) { ...@@ -734,7 +735,7 @@ func TestSelector(t *testing.T) {
if err != nil || singleItemImplied || len(test.Infos) != 3 { if err != nil || singleItemImplied || len(test.Infos) != 3 {
t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos) t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos)
} }
if !api.Semantic.DeepDerivative([]runtime.Object{&pods.Items[0], &pods.Items[1], &svc.Items[0]}, test.Objects()) { if !apiequality.Semantic.DeepDerivative([]runtime.Object{&pods.Items[0], &pods.Items[1], &svc.Items[0]}, test.Objects()) {
t.Errorf("unexpected visited objects: %#v", test.Objects()) t.Errorf("unexpected visited objects: %#v", test.Objects())
} }
...@@ -866,7 +867,7 @@ func TestStream(t *testing.T) { ...@@ -866,7 +867,7 @@ func TestStream(t *testing.T) {
if err != nil || singleItemImplied || len(test.Infos) != 3 { if err != nil || singleItemImplied || len(test.Infos) != 3 {
t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos) t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos)
} }
if !api.Semantic.DeepDerivative([]runtime.Object{&pods.Items[0], &pods.Items[1], &rc.Items[0]}, test.Objects()) { if !apiequality.Semantic.DeepDerivative([]runtime.Object{&pods.Items[0], &pods.Items[1], &rc.Items[0]}, test.Objects()) {
t.Errorf("unexpected visited objects: %#v", test.Objects()) t.Errorf("unexpected visited objects: %#v", test.Objects())
} }
} }
...@@ -883,7 +884,7 @@ func TestYAMLStream(t *testing.T) { ...@@ -883,7 +884,7 @@ func TestYAMLStream(t *testing.T) {
if err != nil || singleItemImplied || len(test.Infos) != 3 { if err != nil || singleItemImplied || len(test.Infos) != 3 {
t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos) t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos)
} }
if !api.Semantic.DeepDerivative([]runtime.Object{&pods.Items[0], &pods.Items[1], &rc.Items[0]}, test.Objects()) { if !apiequality.Semantic.DeepDerivative([]runtime.Object{&pods.Items[0], &pods.Items[1], &rc.Items[0]}, test.Objects()) {
t.Errorf("unexpected visited objects: %#v", test.Objects()) t.Errorf("unexpected visited objects: %#v", test.Objects())
} }
} }
...@@ -905,7 +906,7 @@ func TestMultipleObject(t *testing.T) { ...@@ -905,7 +906,7 @@ func TestMultipleObject(t *testing.T) {
&svc.Items[0], &svc.Items[0],
}, },
} }
if !api.Semantic.DeepDerivative(expected, obj) { if !apiequality.Semantic.DeepDerivative(expected, obj) {
t.Errorf("unexpected visited objects: %#v", obj) t.Errorf("unexpected visited objects: %#v", obj)
} }
} }
...@@ -1136,7 +1137,7 @@ func TestLatest(t *testing.T) { ...@@ -1136,7 +1137,7 @@ func TestLatest(t *testing.T) {
if err != nil || singleItemImplied || len(test.Infos) != 3 { if err != nil || singleItemImplied || len(test.Infos) != 3 {
t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos) t.Fatalf("unexpected response: %v %t %#v", err, singleItemImplied, test.Infos)
} }
if !api.Semantic.DeepDerivative([]runtime.Object{newPod, newPod2, newSvc}, test.Objects()) { if !apiequality.Semantic.DeepDerivative([]runtime.Object{newPod, newPod2, newSvc}, test.Objects()) {
t.Errorf("unexpected visited objects: %#v", test.Objects()) t.Errorf("unexpected visited objects: %#v", test.Objects())
} }
} }
......
...@@ -19,11 +19,11 @@ package config ...@@ -19,11 +19,11 @@ package config
import ( import (
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types" kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
) )
...@@ -71,7 +71,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) { ...@@ -71,7 +71,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
} }
update := got.(kubetypes.PodUpdate) update := got.(kubetypes.PodUpdate)
expected := CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod1v1) expected := CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod1v1)
if !api.Semantic.DeepEqual(expected, update) { if !apiequality.Semantic.DeepEqual(expected, update) {
t.Errorf("Expected %#v; Got %#v", expected, update) t.Errorf("Expected %#v; Got %#v", expected, update)
} }
...@@ -86,7 +86,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) { ...@@ -86,7 +86,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
expectedA := CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod1v1, pod2) expectedA := CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod1v1, pod2)
expectedB := CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod2, pod1v1) expectedB := CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod2, pod1v1)
if !api.Semantic.DeepEqual(expectedA, update) && !api.Semantic.DeepEqual(expectedB, update) { if !apiequality.Semantic.DeepEqual(expectedA, update) && !apiequality.Semantic.DeepEqual(expectedB, update) {
t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, update) t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, update)
} }
...@@ -100,7 +100,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) { ...@@ -100,7 +100,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
expectedA = CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod1v2, pod2) expectedA = CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod1v2, pod2)
expectedB = CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod2, pod1v2) expectedB = CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod2, pod1v2)
if !api.Semantic.DeepEqual(expectedA, update) && !api.Semantic.DeepEqual(expectedB, update) { if !apiequality.Semantic.DeepEqual(expectedA, update) && !apiequality.Semantic.DeepEqual(expectedB, update) {
t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, update) t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, update)
} }
...@@ -112,7 +112,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) { ...@@ -112,7 +112,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
} }
update = got.(kubetypes.PodUpdate) update = got.(kubetypes.PodUpdate)
expected = CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod2) expected = CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource, pod2)
if !api.Semantic.DeepEqual(expected, update) { if !apiequality.Semantic.DeepEqual(expected, update) {
t.Errorf("Expected %#v, Got %#v", expected, update) t.Errorf("Expected %#v, Got %#v", expected, update)
} }
...@@ -124,7 +124,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) { ...@@ -124,7 +124,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
} }
update = got.(kubetypes.PodUpdate) update = got.(kubetypes.PodUpdate)
expected = CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource) expected = CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource)
if !api.Semantic.DeepEqual(expected, update) { if !apiequality.Semantic.DeepEqual(expected, update) {
t.Errorf("Expected %#v, Got %#v", expected, update) t.Errorf("Expected %#v, Got %#v", expected, update)
} }
} }
...@@ -188,7 +188,7 @@ func TestNewSourceApiserverInitialEmptySendsEmptyPodUpdate(t *testing.T) { ...@@ -188,7 +188,7 @@ func TestNewSourceApiserverInitialEmptySendsEmptyPodUpdate(t *testing.T) {
} }
update := got.(kubetypes.PodUpdate) update := got.(kubetypes.PodUpdate)
expected := CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource) expected := CreatePodUpdate(kubetypes.SET, kubetypes.ApiserverSource)
if !api.Semantic.DeepEqual(expected, update) { if !apiequality.Semantic.DeepEqual(expected, update) {
t.Errorf("Expected %#v; Got %#v", expected, update) t.Errorf("Expected %#v; Got %#v", expected, update)
} }
} }
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
...@@ -101,7 +102,7 @@ func expectPodUpdate(t *testing.T, ch <-chan kubetypes.PodUpdate, expected ...ku ...@@ -101,7 +102,7 @@ func expectPodUpdate(t *testing.T, ch <-chan kubetypes.PodUpdate, expected ...ku
// except for "Pods", which are compared separately below. // except for "Pods", which are compared separately below.
expectedCopy, updateCopy := expected[i], update expectedCopy, updateCopy := expected[i], update
expectedCopy.Pods, updateCopy.Pods = nil, nil expectedCopy.Pods, updateCopy.Pods = nil, nil
if !api.Semantic.DeepEqual(expectedCopy, updateCopy) { if !apiequality.Semantic.DeepEqual(expectedCopy, updateCopy) {
t.Fatalf("Expected %#v, Got %#v", expectedCopy, updateCopy) t.Fatalf("Expected %#v, Got %#v", expectedCopy, updateCopy)
} }
......
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
...@@ -58,7 +59,7 @@ func TestUpdateOnNonExistentFile(t *testing.T) { ...@@ -58,7 +59,7 @@ func TestUpdateOnNonExistentFile(t *testing.T) {
case got := <-ch: case got := <-ch:
update := got.(kubetypes.PodUpdate) update := got.(kubetypes.PodUpdate)
expected := CreatePodUpdate(kubetypes.SET, kubetypes.FileSource) expected := CreatePodUpdate(kubetypes.SET, kubetypes.FileSource)
if !api.Semantic.DeepDerivative(expected, update) { if !apiequality.Semantic.DeepDerivative(expected, update) {
t.Fatalf("expected %#v, Got %#v", expected, update) t.Fatalf("expected %#v, Got %#v", expected, update)
} }
...@@ -95,7 +96,7 @@ func TestReadPodsFromFileExistAlready(t *testing.T) { ...@@ -95,7 +96,7 @@ func TestReadPodsFromFileExistAlready(t *testing.T) {
t.Fatalf("%s: Invalid pod %#v, %#v", testCase.desc, internalPod, errs) t.Fatalf("%s: Invalid pod %#v, %#v", testCase.desc, internalPod, errs)
} }
} }
if !api.Semantic.DeepEqual(testCase.expected, update) { if !apiequality.Semantic.DeepEqual(testCase.expected, update) {
t.Fatalf("%s: Expected %#v, Got %#v", testCase.desc, testCase.expected, update) t.Fatalf("%s: Expected %#v, Got %#v", testCase.desc, testCase.expected, update)
} }
case <-time.After(wait.ForeverTestTimeout): case <-time.After(wait.ForeverTestTimeout):
...@@ -159,7 +160,7 @@ func TestExtractFromEmptyDir(t *testing.T) { ...@@ -159,7 +160,7 @@ func TestExtractFromEmptyDir(t *testing.T) {
update := (<-ch).(kubetypes.PodUpdate) update := (<-ch).(kubetypes.PodUpdate)
expected := CreatePodUpdate(kubetypes.SET, kubetypes.FileSource) expected := CreatePodUpdate(kubetypes.SET, kubetypes.FileSource)
if !api.Semantic.DeepEqual(expected, update) { if !apiequality.Semantic.DeepEqual(expected, update) {
t.Fatalf("expected %#v, Got %#v", expected, update) t.Fatalf("expected %#v, Got %#v", expected, update)
} }
} }
...@@ -375,7 +376,7 @@ func expectUpdate(t *testing.T, ch chan interface{}, testCase *testCase) { ...@@ -375,7 +376,7 @@ func expectUpdate(t *testing.T, ch chan interface{}, testCase *testCase) {
} }
} }
if !api.Semantic.DeepEqual(testCase.expected, update) { if !apiequality.Semantic.DeepEqual(testCase.expected, update) {
t.Fatalf("%s: Expected: %#v, Got: %#v", testCase.desc, testCase.expected, update) t.Fatalf("%s: Expected: %#v, Got: %#v", testCase.desc, testCase.expected, update)
} }
return return
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
...@@ -309,7 +310,7 @@ func TestExtractPodsFromHTTP(t *testing.T) { ...@@ -309,7 +310,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
} }
update := (<-ch).(kubetypes.PodUpdate) update := (<-ch).(kubetypes.PodUpdate)
if !api.Semantic.DeepEqual(testCase.expected, update) { if !apiequality.Semantic.DeepEqual(testCase.expected, update) {
t.Errorf("%s: Expected: %#v, Got: %#v", testCase.desc, testCase.expected, update) t.Errorf("%s: Expected: %#v, Got: %#v", testCase.desc, testCase.expected, update)
} }
for _, pod := range update.Pods { for _, pod := range update.Pods {
......
...@@ -37,13 +37,13 @@ import ( ...@@ -37,13 +37,13 @@ import (
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
cadvisorapi "github.com/google/cadvisor/info/v1" cadvisorapi "github.com/google/cadvisor/info/v1"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
kubetypes "k8s.io/apimachinery/pkg/types" kubetypes "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/util/clock" "k8s.io/client-go/util/clock"
"k8s.io/client-go/util/flowcontrol" "k8s.io/client-go/util/flowcontrol"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi" "k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/componentconfig" "k8s.io/kubernetes/pkg/apis/componentconfig"
...@@ -327,10 +327,10 @@ func TestSetEntrypointAndCommand(t *testing.T) { ...@@ -327,10 +327,10 @@ func TestSetEntrypointAndCommand(t *testing.T) {
} }
setEntrypointAndCommand(tc.container, opts, actualOpts) setEntrypointAndCommand(tc.container, opts, actualOpts)
if e, a := tc.expected.Config.Entrypoint, actualOpts.Config.Entrypoint; !api.Semantic.DeepEqual(e, a) { if e, a := tc.expected.Config.Entrypoint, actualOpts.Config.Entrypoint; !apiequality.Semantic.DeepEqual(e, a) {
t.Errorf("%v: unexpected entrypoint: expected %v, got %v", tc.name, e, a) t.Errorf("%v: unexpected entrypoint: expected %v, got %v", tc.name, e, a)
} }
if e, a := tc.expected.Config.Cmd, actualOpts.Config.Cmd; !api.Semantic.DeepEqual(e, a) { if e, a := tc.expected.Config.Cmd, actualOpts.Config.Cmd; !apiequality.Semantic.DeepEqual(e, a) {
t.Errorf("%v: unexpected command: expected %v, got %v", tc.name, e, a) t.Errorf("%v: unexpected command: expected %v, got %v", tc.name, e, a)
} }
} }
......
...@@ -28,6 +28,7 @@ import ( ...@@ -28,6 +28,7 @@ import (
cadvisorapi "github.com/google/cadvisor/info/v1" cadvisorapi "github.com/google/cadvisor/info/v1"
cadvisorapiv2 "github.com/google/cadvisor/info/v2" cadvisorapiv2 "github.com/google/cadvisor/info/v2"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -38,7 +39,6 @@ import ( ...@@ -38,7 +39,6 @@ import (
"k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
core "k8s.io/client-go/testing" core "k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
...@@ -245,7 +245,7 @@ func TestUpdateNewNodeStatus(t *testing.T) { ...@@ -245,7 +245,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
if maxImagesInNodeStatus != len(updatedNode.Status.Images) { if maxImagesInNodeStatus != len(updatedNode.Status.Images) {
t.Errorf("unexpected image list length in node status, expected: %v, got: %v", maxImagesInNodeStatus, len(updatedNode.Status.Images)) t.Errorf("unexpected image list length in node status, expected: %v, got: %v", maxImagesInNodeStatus, len(updatedNode.Status.Images))
} else { } else {
if !api.Semantic.DeepEqual(expectedNode, updatedNode) { if !apiequality.Semantic.DeepEqual(expectedNode, updatedNode) {
t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode)) t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode))
} }
} }
...@@ -519,7 +519,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) { ...@@ -519,7 +519,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
t.Errorf("unexpected node condition order. NodeReady should be last.") t.Errorf("unexpected node condition order. NodeReady should be last.")
} }
if !api.Semantic.DeepEqual(expectedNode, updatedNode) { if !apiequality.Semantic.DeepEqual(expectedNode, updatedNode) {
t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode)) t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode))
} }
} }
...@@ -829,7 +829,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) { ...@@ -829,7 +829,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
LastHeartbeatTime: metav1.Time{}, LastHeartbeatTime: metav1.Time{},
LastTransitionTime: metav1.Time{}, LastTransitionTime: metav1.Time{},
} }
if !api.Semantic.DeepEqual(expectedNode, updatedNode) { if !apiequality.Semantic.DeepEqual(expectedNode, updatedNode) {
t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode)) t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode))
} }
} }
......
...@@ -23,8 +23,8 @@ import ( ...@@ -23,8 +23,8 @@ import (
cadvisorapi "github.com/google/cadvisor/info/v1" cadvisorapi "github.com/google/cadvisor/info/v1"
cadvisorapiv2 "github.com/google/cadvisor/info/v2" cadvisorapiv2 "github.com/google/cadvisor/info/v2"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types" kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
) )
...@@ -78,7 +78,7 @@ func TestPodResourceLimitsDefaulting(t *testing.T) { ...@@ -78,7 +78,7 @@ func TestPodResourceLimitsDefaulting(t *testing.T) {
for idx, tc := range cases { for idx, tc := range cases {
actual, _, err := tk.kubelet.defaultPodLimitsForDownwardApi(tc.pod, nil) actual, _, err := tk.kubelet.defaultPodLimitsForDownwardApi(tc.pod, nil)
as.Nil(err, "failed to default pod limits: %v", err) as.Nil(err, "failed to default pod limits: %v", err)
if !api.Semantic.DeepEqual(tc.expected, actual) { if !apiequality.Semantic.DeepEqual(tc.expected, actual) {
as.Fail("test case [%d] failed. Expected: %+v, Got: %+v", idx, tc.expected, actual) as.Fail("test case [%d] failed. Expected: %+v, Got: %+v", idx, tc.expected, actual)
} }
} }
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"github.com/golang/glog" "github.com/golang/glog"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
...@@ -116,7 +117,7 @@ func NewManager(kubeClient clientset.Interface, podManager kubepod.Manager) Mana ...@@ -116,7 +117,7 @@ func NewManager(kubeClient clientset.Interface, podManager kubepod.Manager) Mana
// This method normalizes the status before comparing so as to make sure that meaningless // This method normalizes the status before comparing so as to make sure that meaningless
// changes will be ignored. // changes will be ignored.
func isStatusEqual(oldStatus, status *v1.PodStatus) bool { func isStatusEqual(oldStatus, status *v1.PodStatus) bool {
return api.Semantic.DeepEqual(status, oldStatus) return apiequality.Semantic.DeepEqual(status, oldStatus)
} }
func (m *manager) Start() { func (m *manager) Start() {
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
...@@ -69,7 +70,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) { ...@@ -69,7 +70,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
t.Errorf("Unable to read from channel when expected") t.Errorf("Unable to read from channel when expected")
} }
expected := ServiceUpdate{Op: SET, Services: []api.Service{}} expected := ServiceUpdate{Op: SET, Services: []api.Service{}}
if !api.Semantic.DeepEqual(expected, got) { if !apiequality.Semantic.DeepEqual(expected, got) {
t.Errorf("Expected %#v; Got %#v", expected, got) t.Errorf("Expected %#v; Got %#v", expected, got)
} }
...@@ -80,7 +81,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) { ...@@ -80,7 +81,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
t.Errorf("Unable to read from channel when expected") t.Errorf("Unable to read from channel when expected")
} }
expected = ServiceUpdate{Op: SET, Services: []api.Service{*service1v1}} expected = ServiceUpdate{Op: SET, Services: []api.Service{*service1v1}}
if !api.Semantic.DeepEqual(expected, got) { if !apiequality.Semantic.DeepEqual(expected, got) {
t.Errorf("Expected %#v; Got %#v", expected, got) t.Errorf("Expected %#v; Got %#v", expected, got)
} }
...@@ -94,7 +95,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) { ...@@ -94,7 +95,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
expectedA := ServiceUpdate{Op: SET, Services: []api.Service{*service1v1, *service2}} expectedA := ServiceUpdate{Op: SET, Services: []api.Service{*service1v1, *service2}}
expectedB := ServiceUpdate{Op: SET, Services: []api.Service{*service2, *service1v1}} expectedB := ServiceUpdate{Op: SET, Services: []api.Service{*service2, *service1v1}}
if !api.Semantic.DeepEqual(expectedA, got) && !api.Semantic.DeepEqual(expectedB, got) { if !apiequality.Semantic.DeepEqual(expectedA, got) && !apiequality.Semantic.DeepEqual(expectedB, got) {
t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, got) t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, got)
} }
...@@ -107,7 +108,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) { ...@@ -107,7 +108,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
expectedA = ServiceUpdate{Op: SET, Services: []api.Service{*service1v2, *service2}} expectedA = ServiceUpdate{Op: SET, Services: []api.Service{*service1v2, *service2}}
expectedB = ServiceUpdate{Op: SET, Services: []api.Service{*service2, *service1v2}} expectedB = ServiceUpdate{Op: SET, Services: []api.Service{*service2, *service1v2}}
if !api.Semantic.DeepEqual(expectedA, got) && !api.Semantic.DeepEqual(expectedB, got) { if !apiequality.Semantic.DeepEqual(expectedA, got) && !apiequality.Semantic.DeepEqual(expectedB, got) {
t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, got) t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, got)
} }
...@@ -118,7 +119,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) { ...@@ -118,7 +119,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
t.Errorf("Unable to read from channel when expected") t.Errorf("Unable to read from channel when expected")
} }
expected = ServiceUpdate{Op: SET, Services: []api.Service{*service2}} expected = ServiceUpdate{Op: SET, Services: []api.Service{*service2}}
if !api.Semantic.DeepEqual(expected, got) { if !apiequality.Semantic.DeepEqual(expected, got) {
t.Errorf("Expected %#v, Got %#v", expected, got) t.Errorf("Expected %#v, Got %#v", expected, got)
} }
...@@ -129,7 +130,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) { ...@@ -129,7 +130,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
t.Errorf("Unable to read from channel when expected") t.Errorf("Unable to read from channel when expected")
} }
expected = ServiceUpdate{Op: SET, Services: []api.Service{}} expected = ServiceUpdate{Op: SET, Services: []api.Service{}}
if !api.Semantic.DeepEqual(expected, got) { if !apiequality.Semantic.DeepEqual(expected, got) {
t.Errorf("Expected %#v, Got %#v", expected, got) t.Errorf("Expected %#v, Got %#v", expected, got)
} }
} }
...@@ -180,7 +181,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) { ...@@ -180,7 +181,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
t.Errorf("Unable to read from channel when expected") t.Errorf("Unable to read from channel when expected")
} }
expected := EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{}} expected := EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{}}
if !api.Semantic.DeepEqual(expected, got) { if !apiequality.Semantic.DeepEqual(expected, got) {
t.Errorf("Expected %#v; Got %#v", expected, got) t.Errorf("Expected %#v; Got %#v", expected, got)
} }
...@@ -191,7 +192,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) { ...@@ -191,7 +192,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
t.Errorf("Unable to read from channel when expected") t.Errorf("Unable to read from channel when expected")
} }
expected = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints1v1}} expected = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints1v1}}
if !api.Semantic.DeepEqual(expected, got) { if !apiequality.Semantic.DeepEqual(expected, got) {
t.Errorf("Expected %#v; Got %#v", expected, got) t.Errorf("Expected %#v; Got %#v", expected, got)
} }
...@@ -205,7 +206,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) { ...@@ -205,7 +206,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
expectedA := EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints1v1, *endpoints2}} expectedA := EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints1v1, *endpoints2}}
expectedB := EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints2, *endpoints1v1}} expectedB := EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints2, *endpoints1v1}}
if !api.Semantic.DeepEqual(expectedA, got) && !api.Semantic.DeepEqual(expectedB, got) { if !apiequality.Semantic.DeepEqual(expectedA, got) && !apiequality.Semantic.DeepEqual(expectedB, got) {
t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, got) t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, got)
} }
...@@ -218,7 +219,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) { ...@@ -218,7 +219,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
expectedA = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints1v2, *endpoints2}} expectedA = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints1v2, *endpoints2}}
expectedB = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints2, *endpoints1v2}} expectedB = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints2, *endpoints1v2}}
if !api.Semantic.DeepEqual(expectedA, got) && !api.Semantic.DeepEqual(expectedB, got) { if !apiequality.Semantic.DeepEqual(expectedA, got) && !apiequality.Semantic.DeepEqual(expectedB, got) {
t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, got) t.Errorf("Expected %#v or %#v, Got %#v", expectedA, expectedB, got)
} }
...@@ -229,7 +230,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) { ...@@ -229,7 +230,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
t.Errorf("Unable to read from channel when expected") t.Errorf("Unable to read from channel when expected")
} }
expected = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints2}} expected = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{*endpoints2}}
if !api.Semantic.DeepEqual(expected, got) { if !apiequality.Semantic.DeepEqual(expected, got) {
t.Errorf("Expected %#v, Got %#v", expected, got) t.Errorf("Expected %#v, Got %#v", expected, got)
} }
...@@ -240,7 +241,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) { ...@@ -240,7 +241,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
t.Errorf("Unable to read from channel when expected") t.Errorf("Unable to read from channel when expected")
} }
expected = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{}} expected = EndpointsUpdate{Op: SET, Endpoints: []api.Endpoints{}}
if !api.Semantic.DeepEqual(expected, got) { if !apiequality.Semantic.DeepEqual(expected, got) {
t.Errorf("Expected %#v, Got %#v", expected, got) t.Errorf("Expected %#v, Got %#v", expected, got)
} }
} }
...@@ -19,6 +19,7 @@ package storage ...@@ -19,6 +19,7 @@ package storage
import ( import (
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -190,7 +191,7 @@ func TestUpdateStatus(t *testing.T) { ...@@ -190,7 +191,7 @@ func TestUpdateStatus(t *testing.T) {
} }
pvOut := obj.(*api.PersistentVolume) pvOut := obj.(*api.PersistentVolume)
// only compare the relevant change b/c metadata will differ // only compare the relevant change b/c metadata will differ
if !api.Semantic.DeepEqual(pvIn.Status, pvOut.Status) { if !apiequality.Semantic.DeepEqual(pvIn.Status, pvOut.Status) {
t.Errorf("unexpected object: %s", diff.ObjectDiff(pvIn.Status, pvOut.Status)) t.Errorf("unexpected object: %s", diff.ObjectDiff(pvIn.Status, pvOut.Status))
} }
} }
...@@ -19,6 +19,7 @@ package storage ...@@ -19,6 +19,7 @@ package storage
import ( import (
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -187,7 +188,7 @@ func TestUpdateStatus(t *testing.T) { ...@@ -187,7 +188,7 @@ func TestUpdateStatus(t *testing.T) {
} }
pvcOut := obj.(*api.PersistentVolumeClaim) pvcOut := obj.(*api.PersistentVolumeClaim)
// only compare relevant changes b/c of difference in metadata // only compare relevant changes b/c of difference in metadata
if !api.Semantic.DeepEqual(pvc.Status, pvcOut.Status) { if !apiequality.Semantic.DeepEqual(pvc.Status, pvcOut.Status) {
t.Errorf("unexpected object: %s", diff.ObjectDiff(pvc.Status, pvcOut.Status)) t.Errorf("unexpected object: %s", diff.ObjectDiff(pvc.Status, pvcOut.Status))
} }
} }
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"testing" "testing"
"golang.org/x/net/context" "golang.org/x/net/context"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -634,7 +635,7 @@ func TestEtcdUpdateNotScheduled(t *testing.T) { ...@@ -634,7 +635,7 @@ func TestEtcdUpdateNotScheduled(t *testing.T) {
} }
podOut := obj.(*api.Pod) podOut := obj.(*api.Pod)
// validChangedPod only changes the Labels, so were checking the update was valid // validChangedPod only changes the Labels, so were checking the update was valid
if !api.Semantic.DeepEqual(podIn.Labels, podOut.Labels) { if !apiequality.Semantic.DeepEqual(podIn.Labels, podOut.Labels) {
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn)) t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn))
} }
} }
...@@ -705,7 +706,7 @@ func TestEtcdUpdateScheduled(t *testing.T) { ...@@ -705,7 +706,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
} }
podOut := obj.(*api.Pod) podOut := obj.(*api.Pod)
// Check to verify the Spec and Label updates match from change above. Those are the fields changed. // Check to verify the Spec and Label updates match from change above. Those are the fields changed.
if !api.Semantic.DeepEqual(podOut.Spec, podIn.Spec) || !api.Semantic.DeepEqual(podOut.Labels, podIn.Labels) { if !apiequality.Semantic.DeepEqual(podOut.Spec, podIn.Spec) || !apiequality.Semantic.DeepEqual(podOut.Labels, podIn.Labels) {
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn)) t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn))
} }
...@@ -788,9 +789,9 @@ func TestEtcdUpdateStatus(t *testing.T) { ...@@ -788,9 +789,9 @@ func TestEtcdUpdateStatus(t *testing.T) {
} }
podOut := obj.(*api.Pod) podOut := obj.(*api.Pod)
// Check to verify the Label, and Status updates match from change above. Those are the fields changed. // Check to verify the Label, and Status updates match from change above. Those are the fields changed.
if !api.Semantic.DeepEqual(podOut.Spec, expected.Spec) || if !apiequality.Semantic.DeepEqual(podOut.Spec, expected.Spec) ||
!api.Semantic.DeepEqual(podOut.Labels, expected.Labels) || !apiequality.Semantic.DeepEqual(podOut.Labels, expected.Labels) ||
!api.Semantic.DeepEqual(podOut.Status, expected.Status) { !apiequality.Semantic.DeepEqual(podOut.Status, expected.Status) {
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, expected)) t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, expected))
} }
} }
...@@ -19,6 +19,7 @@ package storage ...@@ -19,6 +19,7 @@ package storage
import ( import (
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -284,7 +285,7 @@ func TestScaleGet(t *testing.T) { ...@@ -284,7 +285,7 @@ func TestScaleGet(t *testing.T) {
t.Fatalf("error fetching scale for %s: %v", name, err) t.Fatalf("error fetching scale for %s: %v", name, err)
} }
got := obj.(*autoscaling.Scale) got := obj.(*autoscaling.Scale)
if !api.Semantic.DeepEqual(want, got) { if !apiequality.Semantic.DeepEqual(want, got) {
t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got)) t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got))
} }
} }
......
...@@ -19,6 +19,7 @@ package storage ...@@ -19,6 +19,7 @@ package storage
import ( import (
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -197,7 +198,7 @@ func TestUpdateStatus(t *testing.T) { ...@@ -197,7 +198,7 @@ func TestUpdateStatus(t *testing.T) {
obj, err := storage.Get(ctx, "foo", &metav1.GetOptions{}) obj, err := storage.Get(ctx, "foo", &metav1.GetOptions{})
rqOut := obj.(*api.ResourceQuota) rqOut := obj.(*api.ResourceQuota)
// only compare the meaningful update b/c we can't compare due to metadata // only compare the meaningful update b/c we can't compare due to metadata
if !api.Semantic.DeepEqual(resourcequotaIn.Status, rqOut.Status) { if !apiequality.Semantic.DeepEqual(resourcequotaIn.Status, rqOut.Status) {
t.Errorf("unexpected object: %s", diff.ObjectDiff(resourcequotaIn, rqOut)) t.Errorf("unexpected object: %s", diff.ObjectDiff(resourcequotaIn, rqOut))
} }
} }
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"reflect" "reflect"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -226,7 +227,7 @@ func TestScaleGet(t *testing.T) { ...@@ -226,7 +227,7 @@ func TestScaleGet(t *testing.T) {
t.Fatalf("error fetching scale for %s: %v", name, err) t.Fatalf("error fetching scale for %s: %v", name, err)
} }
got := obj.(*extensions.Scale) got := obj.(*extensions.Scale)
if !api.Semantic.DeepEqual(want, got) { if !apiequality.Semantic.DeepEqual(want, got) {
t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got)) t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got))
} }
} }
......
...@@ -19,6 +19,7 @@ package storage ...@@ -19,6 +19,7 @@ package storage
import ( import (
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -281,7 +282,7 @@ func TestScaleGet(t *testing.T) { ...@@ -281,7 +282,7 @@ func TestScaleGet(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("error fetching scale for %s: %v", name, err) t.Fatalf("error fetching scale for %s: %v", name, err)
} }
if !api.Semantic.DeepEqual(got, want) { if !apiequality.Semantic.DeepEqual(got, want) {
t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want)) t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want))
} }
} }
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -282,7 +283,7 @@ func verifyWatchEvent(t *testing.T, w watch.Interface, eventType watch.EventType ...@@ -282,7 +283,7 @@ func verifyWatchEvent(t *testing.T, w watch.Interface, eventType watch.EventType
t.Logf("(called from line %d)", line) t.Logf("(called from line %d)", line)
t.Errorf("Expected: %s, got: %s", eventType, event.Type) t.Errorf("Expected: %s, got: %s", eventType, event.Type)
} }
if e, a := eventObject, event.Object; !api.Semantic.DeepDerivative(e, a) { if e, a := eventObject, event.Object; !apiequality.Semantic.DeepDerivative(e, a) {
t.Logf("(called from line %d)", line) t.Logf("(called from line %d)", line)
t.Errorf("Expected (%s): %#v, got: %#v", eventType, e, a) t.Errorf("Expected (%s): %#v, got: %#v", eventType, e, a)
} }
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
rt "runtime" rt "runtime"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
...@@ -139,7 +140,7 @@ func TestWatchInterpretations(t *testing.T) { ...@@ -139,7 +140,7 @@ func TestWatchInterpretations(t *testing.T) {
if e, a := item.expectType, event.Type; e != a { if e, a := item.expectType, event.Type; e != a {
t.Errorf("'%v - %v': expected %v, got %v", name, action, e, a) t.Errorf("'%v - %v': expected %v, got %v", name, action, e, a)
} }
if e, a := item.expectObject, event.Object; !api.Semantic.DeepDerivative(e, a) { if e, a := item.expectObject, event.Object; !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("'%v - %v': expected %v, got %v", name, action, e, a) t.Errorf("'%v - %v': expected %v, got %v", name, action, e, a)
} }
} }
...@@ -311,7 +312,7 @@ func TestWatch(t *testing.T) { ...@@ -311,7 +312,7 @@ func TestWatch(t *testing.T) {
if e, a := watch.Added, event.Type; e != a { if e, a := watch.Added, event.Type; e != a {
t.Errorf("Expected %v, got %v", e, a) t.Errorf("Expected %v, got %v", e, a)
} }
if e, a := pod, event.Object; !api.Semantic.DeepDerivative(e, a) { if e, a := pod, event.Object; !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("Expected %v, got %v", e, a) t.Errorf("Expected %v, got %v", e, a)
} }
...@@ -391,7 +392,7 @@ func TestWatchEtcdState(t *testing.T) { ...@@ -391,7 +392,7 @@ func TestWatchEtcdState(t *testing.T) {
t.Errorf("Unexpected event %#v", event) t.Errorf("Unexpected event %#v", event)
} }
if e, a := endpoint, event.Object; !api.Semantic.DeepDerivative(e, a) { if e, a := endpoint, event.Object; !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("Unexpected error: expected %#v, got %#v", e, a) t.Errorf("Unexpected error: expected %#v, got %#v", e, a)
} }
} }
...@@ -464,7 +465,7 @@ func TestWatchFromZeroIndex(t *testing.T) { ...@@ -464,7 +465,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
t.Errorf("Unexpected event %#v", event) t.Errorf("Unexpected event %#v", event)
} }
if e, a := pod, event.Object; a == nil || !api.Semantic.DeepDerivative(e, a) { if e, a := pod, event.Object; a == nil || !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("Unexpected error: expected %#v, got %#v", e, a) t.Errorf("Unexpected error: expected %#v, got %#v", e, a)
} }
} }
...@@ -494,7 +495,7 @@ func TestWatchListFromZeroIndex(t *testing.T) { ...@@ -494,7 +495,7 @@ func TestWatchListFromZeroIndex(t *testing.T) {
t.Errorf("Unexpected event %#v", event) t.Errorf("Unexpected event %#v", event)
} }
if e, a := pod, event.Object; !api.Semantic.DeepDerivative(e, a) { if e, a := pod, event.Object; !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("Unexpected error: expected %v, got %v", e, a) t.Errorf("Unexpected error: expected %v, got %v", e, a)
} }
} }
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
...@@ -68,7 +69,7 @@ func TestWatchCacheBasic(t *testing.T) { ...@@ -68,7 +69,7 @@ func TestWatchCacheBasic(t *testing.T) {
if item, ok, _ := store.Get(pod1); !ok { if item, ok, _ := store.Get(pod1); !ok {
t.Errorf("didn't find pod") t.Errorf("didn't find pod")
} else { } else {
if !api.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/pod", Object: pod1}, item) { if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/pod", Object: pod1}, item) {
t.Errorf("expected %v, got %v", pod1, item) t.Errorf("expected %v, got %v", pod1, item)
} }
} }
...@@ -79,7 +80,7 @@ func TestWatchCacheBasic(t *testing.T) { ...@@ -79,7 +80,7 @@ func TestWatchCacheBasic(t *testing.T) {
if item, ok, _ := store.Get(pod2); !ok { if item, ok, _ := store.Get(pod2); !ok {
t.Errorf("didn't find pod") t.Errorf("didn't find pod")
} else { } else {
if !api.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/pod", Object: pod2}, item) { if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/pod", Object: pod2}, item) {
t.Errorf("expected %v, got %v", pod1, item) t.Errorf("expected %v, got %v", pod1, item)
} }
} }
...@@ -154,7 +155,7 @@ func TestEvents(t *testing.T) { ...@@ -154,7 +155,7 @@ func TestEvents(t *testing.T) {
t.Errorf("unexpected event type: %v", result[0].Type) t.Errorf("unexpected event type: %v", result[0].Type)
} }
pod := makeTestPod("pod", uint64(3)) pod := makeTestPod("pod", uint64(3))
if !api.Semantic.DeepEqual(pod, result[0].Object) { if !apiequality.Semantic.DeepEqual(pod, result[0].Object) {
t.Errorf("unexpected item: %v, expected: %v", result[0].Object, pod) t.Errorf("unexpected item: %v, expected: %v", result[0].Object, pod)
} }
if result[0].PrevObject != nil { if result[0].PrevObject != nil {
...@@ -185,11 +186,11 @@ func TestEvents(t *testing.T) { ...@@ -185,11 +186,11 @@ func TestEvents(t *testing.T) {
t.Errorf("unexpected event type: %v", result[i].Type) t.Errorf("unexpected event type: %v", result[i].Type)
} }
pod := makeTestPod("pod", uint64(i+4)) pod := makeTestPod("pod", uint64(i+4))
if !api.Semantic.DeepEqual(pod, result[i].Object) { if !apiequality.Semantic.DeepEqual(pod, result[i].Object) {
t.Errorf("unexpected item: %v, expected: %v", result[i].Object, pod) t.Errorf("unexpected item: %v, expected: %v", result[i].Object, pod)
} }
prevPod := makeTestPod("pod", uint64(i+3)) prevPod := makeTestPod("pod", uint64(i+3))
if !api.Semantic.DeepEqual(prevPod, result[i].PrevObject) { if !apiequality.Semantic.DeepEqual(prevPod, result[i].PrevObject) {
t.Errorf("unexpected item: %v, expected: %v", result[i].PrevObject, prevPod) t.Errorf("unexpected item: %v, expected: %v", result[i].PrevObject, prevPod)
} }
} }
...@@ -216,7 +217,7 @@ func TestEvents(t *testing.T) { ...@@ -216,7 +217,7 @@ func TestEvents(t *testing.T) {
} }
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
pod := makeTestPod("pod", uint64(i+5)) pod := makeTestPod("pod", uint64(i+5))
if !api.Semantic.DeepEqual(pod, result[i].Object) { if !apiequality.Semantic.DeepEqual(pod, result[i].Object) {
t.Errorf("unexpected item: %v, expected: %v", result[i].Object, pod) t.Errorf("unexpected item: %v, expected: %v", result[i].Object, pod)
} }
} }
...@@ -237,11 +238,11 @@ func TestEvents(t *testing.T) { ...@@ -237,11 +238,11 @@ func TestEvents(t *testing.T) {
t.Errorf("unexpected event type: %v", result[0].Type) t.Errorf("unexpected event type: %v", result[0].Type)
} }
pod := makeTestPod("pod", uint64(10)) pod := makeTestPod("pod", uint64(10))
if !api.Semantic.DeepEqual(pod, result[0].Object) { if !apiequality.Semantic.DeepEqual(pod, result[0].Object) {
t.Errorf("unexpected item: %v, expected: %v", result[0].Object, pod) t.Errorf("unexpected item: %v, expected: %v", result[0].Object, pod)
} }
prevPod := makeTestPod("pod", uint64(9)) prevPod := makeTestPod("pod", uint64(9))
if !api.Semantic.DeepEqual(prevPod, result[0].PrevObject) { if !apiequality.Semantic.DeepEqual(prevPod, result[0].PrevObject) {
t.Errorf("unexpected item: %v, expected: %v", result[0].PrevObject, prevPod) t.Errorf("unexpected item: %v, expected: %v", result[0].PrevObject, prevPod)
} }
} }
...@@ -287,7 +288,7 @@ func TestWaitUntilFreshAndGet(t *testing.T) { ...@@ -287,7 +288,7 @@ func TestWaitUntilFreshAndGet(t *testing.T) {
if !exists { if !exists {
t.Fatalf("no results returned: %#v", obj) t.Fatalf("no results returned: %#v", obj)
} }
if !api.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/bar", Object: makeTestPod("bar", 5)}, obj) { if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/bar", Object: makeTestPod("bar", 5)}, obj) {
t.Errorf("unexpected element returned: %#v", obj) t.Errorf("unexpected element returned: %#v", obj)
} }
} }
......
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"testing" "testing"
"github.com/pborman/uuid" "github.com/pborman/uuid"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
utiltesting "k8s.io/client-go/util/testing" utiltesting "k8s.io/client-go/util/testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
...@@ -49,7 +50,7 @@ func TestSavePodToFile(t *testing.T) { ...@@ -49,7 +50,7 @@ func TestSavePodToFile(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to load pod from file: %v", err) t.Fatalf("failed to load pod from file: %v", err)
} }
if !api.Semantic.DeepEqual(pod, podFromFile) { if !apiequality.Semantic.DeepEqual(pod, podFromFile) {
t.Errorf("\nexpected %#v\ngot %#v\n", pod, podFromFile) t.Errorf("\nexpected %#v\ngot %#v\n", pod, podFromFile)
} }
} }
...@@ -20,11 +20,11 @@ import ( ...@@ -20,11 +20,11 @@ import (
"fmt" "fmt"
"io" "io"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/kubernetes/pkg/api"
) )
func init() { func init() {
...@@ -91,7 +91,7 @@ func isChangingOwnerReference(newObj, oldObj runtime.Object) bool { ...@@ -91,7 +91,7 @@ func isChangingOwnerReference(newObj, oldObj runtime.Object) bool {
return true return true
} }
for i := range oldOwners { for i := range oldOwners {
if !api.Semantic.DeepEqual(oldOwners[i], newOwners[i]) { if !apiequality.Semantic.DeepEqual(oldOwners[i], newOwners[i]) {
return true return true
} }
} }
......
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
...@@ -166,7 +167,7 @@ func TestDefaultContainerResourceRequirements(t *testing.T) { ...@@ -166,7 +167,7 @@ func TestDefaultContainerResourceRequirements(t *testing.T) {
} }
actual := defaultContainerResourceRequirements(&limitRange) actual := defaultContainerResourceRequirements(&limitRange)
if !api.Semantic.DeepEqual(expected, actual) { if !apiequality.Semantic.DeepEqual(expected, actual) {
t.Errorf("actual.Limits != expected.Limits; %v != %v", actual.Limits, expected.Limits) t.Errorf("actual.Limits != expected.Limits; %v != %v", actual.Limits, expected.Limits)
t.Errorf("actual.Requests != expected.Requests; %v != %v", actual.Requests, expected.Requests) t.Errorf("actual.Requests != expected.Requests; %v != %v", actual.Requests, expected.Requests)
t.Errorf("expected != actual; %v != %v", expected, actual) t.Errorf("expected != actual; %v != %v", expected, actual)
...@@ -199,7 +200,7 @@ func TestMergePodResourceRequirements(t *testing.T) { ...@@ -199,7 +200,7 @@ func TestMergePodResourceRequirements(t *testing.T) {
mergePodResourceRequirements(&pod, &defaultRequirements) mergePodResourceRequirements(&pod, &defaultRequirements)
for i := range pod.Spec.Containers { for i := range pod.Spec.Containers {
actual := pod.Spec.Containers[i].Resources actual := pod.Spec.Containers[i].Resources
if !api.Semantic.DeepEqual(expected, actual) { if !apiequality.Semantic.DeepEqual(expected, actual) {
t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, expected, actual) t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, expected, actual)
} }
} }
...@@ -218,13 +219,13 @@ func TestMergePodResourceRequirements(t *testing.T) { ...@@ -218,13 +219,13 @@ func TestMergePodResourceRequirements(t *testing.T) {
mergePodResourceRequirements(&pod, &defaultRequirements) mergePodResourceRequirements(&pod, &defaultRequirements)
for i := range pod.Spec.Containers { for i := range pod.Spec.Containers {
actual := pod.Spec.Containers[i].Resources actual := pod.Spec.Containers[i].Resources
if !api.Semantic.DeepEqual(expected, actual) { if !apiequality.Semantic.DeepEqual(expected, actual) {
t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, expected, actual) t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, expected, actual)
} }
} }
for i := range pod.Spec.InitContainers { for i := range pod.Spec.InitContainers {
actual := pod.Spec.InitContainers[i].Resources actual := pod.Spec.InitContainers[i].Resources
if !api.Semantic.DeepEqual(expected, actual) { if !apiequality.Semantic.DeepEqual(expected, actual) {
t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, expected, actual) t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, expected, actual)
} }
} }
...@@ -238,13 +239,13 @@ func TestMergePodResourceRequirements(t *testing.T) { ...@@ -238,13 +239,13 @@ func TestMergePodResourceRequirements(t *testing.T) {
mergePodResourceRequirements(&pod, &defaultRequirements) mergePodResourceRequirements(&pod, &defaultRequirements)
for i := range pod.Spec.Containers { for i := range pod.Spec.Containers {
actual := pod.Spec.Containers[i].Resources actual := pod.Spec.Containers[i].Resources
if !api.Semantic.DeepEqual(expected, actual) { if !apiequality.Semantic.DeepEqual(expected, actual) {
t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, expected, actual) t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, expected, actual)
} }
} }
for i := range pod.Spec.InitContainers { for i := range pod.Spec.InitContainers {
actual := pod.Spec.InitContainers[i].Resources actual := pod.Spec.InitContainers[i].Resources
if !api.Semantic.DeepEqual(initInputs[i], actual) { if !apiequality.Semantic.DeepEqual(initInputs[i], actual) {
t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, initInputs[i], actual) t.Errorf("pod %v, expected != actual; %v != %v", pod.Name, initInputs[i], actual)
} }
} }
......
/*
Copyright 2014 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package equality
import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
)
// Semantic can do semantic deep equality checks for api objects.
// Example: apiequality.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
var Semantic = conversion.EqualitiesOrDie(
func(a, b resource.Quantity) bool {
// Ignore formatting, only care that numeric value stayed the same.
// TODO: if we decide it's important, it should be safe to start comparing the format.
//
// Uninitialized quantities are equivalent to 0 quantities.
return a.Cmp(b) == 0
},
func(a, b metav1.Time) bool {
return a.UTC() == b.UTC()
},
func(a, b labels.Selector) bool {
return a.String() == b.String()
},
func(a, b fields.Selector) bool {
return a.String() == b.String()
},
)
...@@ -67,7 +67,7 @@ func NonConvertibleFields(annotations map[string]string) map[string]string { ...@@ -67,7 +67,7 @@ func NonConvertibleFields(annotations map[string]string) map[string]string {
} }
// Semantic can do semantic deep equality checks for api objects. // Semantic can do semantic deep equality checks for api objects.
// Example: api.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true // Example: apiequality.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
var Semantic = conversion.EqualitiesOrDie( var Semantic = conversion.EqualitiesOrDie(
func(a, b resource.Quantity) bool { func(a, b resource.Quantity) bool {
// Ignore formatting, only care that numeric value stayed the same. // Ignore formatting, only care that numeric value stayed the same.
......
...@@ -50,6 +50,7 @@ import ( ...@@ -50,6 +50,7 @@ import (
"k8s.io/client-go/util/clock" "k8s.io/client-go/util/clock"
"k8s.io/client-go/util/flowcontrol" "k8s.io/client-go/util/flowcontrol"
utiltesting "k8s.io/client-go/util/testing" utiltesting "k8s.io/client-go/util/testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
_ "k8s.io/client-go/pkg/api/install" _ "k8s.io/client-go/pkg/api/install"
) )
...@@ -415,7 +416,7 @@ func TestTransformResponse(t *testing.T) { ...@@ -415,7 +416,7 @@ func TestTransformResponse(t *testing.T) {
if test.ErrFn != nil && !test.ErrFn(err) { if test.ErrFn != nil && !test.ErrFn(err) {
t.Errorf("%d: error function did not match: %v", i, err) t.Errorf("%d: error function did not match: %v", i, err)
} }
if !(test.Data == nil && response == nil) && !api.Semantic.DeepDerivative(test.Data, response) { if !(test.Data == nil && response == nil) && !apiequality.Semantic.DeepDerivative(test.Data, response) {
t.Errorf("%d: unexpected response: %#v %#v", i, test.Data, response) t.Errorf("%d: unexpected response: %#v %#v", i, test.Data, response)
} }
if test.Created != created { if test.Created != created {
...@@ -1043,7 +1044,7 @@ func TestDoRequestNewWay(t *testing.T) { ...@@ -1043,7 +1044,7 @@ func TestDoRequestNewWay(t *testing.T) {
} }
if obj == nil { if obj == nil {
t.Error("nil obj") t.Error("nil obj")
} else if !api.Semantic.DeepDerivative(expectedObj, obj) { } else if !apiequality.Semantic.DeepDerivative(expectedObj, obj) {
t.Errorf("Expected: %#v, got %#v", expectedObj, obj) t.Errorf("Expected: %#v, got %#v", expectedObj, obj)
} }
requestURL := defaultResourcePathWithPrefix("foo/bar", "", "", "baz") requestURL := defaultResourcePathWithPrefix("foo/bar", "", "", "baz")
...@@ -1276,7 +1277,7 @@ func TestDoRequestNewWayReader(t *testing.T) { ...@@ -1276,7 +1277,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
} }
if obj == nil { if obj == nil {
t.Error("nil obj") t.Error("nil obj")
} else if !api.Semantic.DeepDerivative(expectedObj, obj) { } else if !apiequality.Semantic.DeepDerivative(expectedObj, obj) {
t.Errorf("Expected: %#v, got %#v", expectedObj, obj) t.Errorf("Expected: %#v, got %#v", expectedObj, obj)
} }
tmpStr := string(reqBodyExpected) tmpStr := string(reqBodyExpected)
...@@ -1316,7 +1317,7 @@ func TestDoRequestNewWayObj(t *testing.T) { ...@@ -1316,7 +1317,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
} }
if obj == nil { if obj == nil {
t.Error("nil obj") t.Error("nil obj")
} else if !api.Semantic.DeepDerivative(expectedObj, obj) { } else if !apiequality.Semantic.DeepDerivative(expectedObj, obj) {
t.Errorf("Expected: %#v, got %#v", expectedObj, obj) t.Errorf("Expected: %#v, got %#v", expectedObj, obj)
} }
tmpStr := string(reqBodyExpected) tmpStr := string(reqBodyExpected)
...@@ -1370,7 +1371,7 @@ func TestDoRequestNewWayFile(t *testing.T) { ...@@ -1370,7 +1371,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
} }
if obj == nil { if obj == nil {
t.Error("nil obj") t.Error("nil obj")
} else if !api.Semantic.DeepDerivative(expectedObj, obj) { } else if !apiequality.Semantic.DeepDerivative(expectedObj, obj) {
t.Errorf("Expected: %#v, got %#v", expectedObj, obj) t.Errorf("Expected: %#v, got %#v", expectedObj, obj)
} }
if wasCreated { if wasCreated {
...@@ -1415,7 +1416,7 @@ func TestWasCreated(t *testing.T) { ...@@ -1415,7 +1416,7 @@ func TestWasCreated(t *testing.T) {
} }
if obj == nil { if obj == nil {
t.Error("nil obj") t.Error("nil obj")
} else if !api.Semantic.DeepDerivative(expectedObj, obj) { } else if !apiequality.Semantic.DeepDerivative(expectedObj, obj) {
t.Errorf("Expected: %#v, got %#v", expectedObj, obj) t.Errorf("Expected: %#v, got %#v", expectedObj, obj)
} }
if !wasCreated { if !wasCreated {
...@@ -1623,7 +1624,7 @@ func TestWatch(t *testing.T) { ...@@ -1623,7 +1624,7 @@ func TestWatch(t *testing.T) {
if e, a := item.t, got.Type; e != a { if e, a := item.t, got.Type; e != a {
t.Errorf("Expected %v, got %v", e, a) t.Errorf("Expected %v, got %v", e, a)
} }
if e, a := item.obj, got.Object; !api.Semantic.DeepDerivative(e, a) { if e, a := item.obj, got.Object; !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("Expected %v, got %v", e, a) t.Errorf("Expected %v, got %v", e, a)
} }
} }
......
...@@ -30,6 +30,7 @@ import ( ...@@ -30,6 +30,7 @@ import (
"k8s.io/client-go/pkg/api" "k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/v1" "k8s.io/client-go/pkg/api/v1"
restclientwatch "k8s.io/client-go/rest/watch" restclientwatch "k8s.io/client-go/rest/watch"
apiequality "k8s.io/apimachinery/pkg/api/equality"
_ "k8s.io/client-go/pkg/api/install" _ "k8s.io/client-go/pkg/api/install"
) )
...@@ -68,7 +69,7 @@ func TestDecoder(t *testing.T) { ...@@ -68,7 +69,7 @@ func TestDecoder(t *testing.T) {
if e, a := eventType, action; e != a { if e, a := eventType, action; e != a {
t.Errorf("Expected %v, got %v", e, a) t.Errorf("Expected %v, got %v", e, a)
} }
if e, a := expect, got; !api.Semantic.DeepDerivative(e, a) { if e, a := expect, got; !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("Expected %v, got %v", e, a) t.Errorf("Expected %v, got %v", e, a)
} }
t.Logf("Exited read") t.Logf("Exited read")
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"io/ioutil" "io/ioutil"
"testing" "testing"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming" "k8s.io/apimachinery/pkg/runtime/serializer/streaming"
...@@ -71,7 +72,7 @@ func TestEncodeDecodeRoundTrip(t *testing.T) { ...@@ -71,7 +72,7 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
t.Errorf("%d: unexpected error: %v", i, err) t.Errorf("%d: unexpected error: %v", i, err)
continue continue
} }
if !api.Semantic.DeepDerivative(testCase.Object, obj) { if !apiequality.Semantic.DeepDerivative(testCase.Object, obj) {
t.Errorf("%d: expected %#v, got %#v", i, testCase.Object, obj) t.Errorf("%d: expected %#v, got %#v", i, testCase.Object, obj)
} }
if event != testCase.Type { if event != testCase.Type {
......
...@@ -31,6 +31,7 @@ import ( ...@@ -31,6 +31,7 @@ import (
"testing" "testing"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
...@@ -259,13 +260,13 @@ func TestServiceAccountTokenAutoMount(t *testing.T) { ...@@ -259,13 +260,13 @@ func TestServiceAccountTokenAutoMount(t *testing.T) {
if createdPod.Spec.ServiceAccountName != expectedServiceAccount { if createdPod.Spec.ServiceAccountName != expectedServiceAccount {
t.Fatalf("Expected %s, got %s", expectedServiceAccount, createdPod.Spec.ServiceAccountName) t.Fatalf("Expected %s, got %s", expectedServiceAccount, createdPod.Spec.ServiceAccountName)
} }
if !api.Semantic.DeepEqual(&expectedVolumes, &createdPod.Spec.Volumes) { if !apiequality.Semantic.DeepEqual(&expectedVolumes, &createdPod.Spec.Volumes) {
t.Fatalf("Expected\n\t%#v\n\tgot\n\t%#v", expectedVolumes, createdPod.Spec.Volumes) t.Fatalf("Expected\n\t%#v\n\tgot\n\t%#v", expectedVolumes, createdPod.Spec.Volumes)
} }
if !api.Semantic.DeepEqual(&expectedContainer1VolumeMounts, &createdPod.Spec.Containers[0].VolumeMounts) { if !apiequality.Semantic.DeepEqual(&expectedContainer1VolumeMounts, &createdPod.Spec.Containers[0].VolumeMounts) {
t.Fatalf("Expected\n\t%#v\n\tgot\n\t%#v", expectedContainer1VolumeMounts, createdPod.Spec.Containers[0].VolumeMounts) t.Fatalf("Expected\n\t%#v\n\tgot\n\t%#v", expectedContainer1VolumeMounts, createdPod.Spec.Containers[0].VolumeMounts)
} }
if !api.Semantic.DeepEqual(&expectedContainer2VolumeMounts, &createdPod.Spec.Containers[1].VolumeMounts) { if !apiequality.Semantic.DeepEqual(&expectedContainer2VolumeMounts, &createdPod.Spec.Containers[1].VolumeMounts) {
t.Fatalf("Expected\n\t%#v\n\tgot\n\t%#v", expectedContainer2VolumeMounts, createdPod.Spec.Containers[1].VolumeMounts) t.Fatalf("Expected\n\t%#v\n\tgot\n\t%#v", expectedContainer2VolumeMounts, createdPod.Spec.Containers[1].VolumeMounts)
} }
} }
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"sync" "sync"
"time" "time"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apierrs "k8s.io/apimachinery/pkg/api/errors" apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -845,7 +846,7 @@ func DoCleanupNode(client clientset.Interface, nodeName string, strategy Prepare ...@@ -845,7 +846,7 @@ func DoCleanupNode(client clientset.Interface, nodeName string, strategy Prepare
return fmt.Errorf("Skipping cleanup of Node: failed to get Node %v: %v", nodeName, err) return fmt.Errorf("Skipping cleanup of Node: failed to get Node %v: %v", nodeName, err)
} }
updatedNode := strategy.CleanupNode(node) updatedNode := strategy.CleanupNode(node)
if api.Semantic.DeepEqual(node, updatedNode) { if apiequality.Semantic.DeepEqual(node, updatedNode) {
return nil return nil
} }
if _, err = client.Core().Nodes().Update(updatedNode); err == nil { if _, err = client.Core().Nodes().Update(updatedNode); err == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment