Replace uses of diff.ObjectDiff with cmp.Diff

ObjectDiff is already a shim over cmp.Diff, so no actual output or
behavior changes
This commit is contained in:
Tim Hockin
2023-03-23 11:29:01 -07:00
parent dd7af241c1
commit 29c0b73d64
55 changed files with 170 additions and 168 deletions

View File

@@ -20,10 +20,10 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
autoscalingv1 "k8s.io/api/autoscaling/v1" autoscalingv1 "k8s.io/api/autoscaling/v1"
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/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install" _ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
@@ -124,7 +124,7 @@ func TestHorizontalPodAutoscalerAnnotations(t *testing.T) {
t.Fatalf("unexpected object: %v", obj) t.Fatalf("unexpected object: %v", obj)
} }
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) { if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
t.Errorf("diff: %v", diff.ObjectDiff(*hpa, hpaBeforeMuatate)) t.Errorf("diff: %v", cmp.Diff(*hpa, hpaBeforeMuatate))
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate) t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
} }

View File

@@ -21,9 +21,9 @@ import (
"testing" "testing"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
autoscalingv2 "k8s.io/api/autoscaling/v2" autoscalingv2 "k8s.io/api/autoscaling/v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -293,7 +293,7 @@ func TestHorizontalPodAutoscalerAnnotations(t *testing.T) {
t.Fatalf("unexpected object: %v", obj) t.Fatalf("unexpected object: %v", obj)
} }
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) { if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
t.Errorf("diff: %v", diff.ObjectDiff(*hpa, hpaBeforeMuatate)) t.Errorf("diff: %v", cmp.Diff(*hpa, hpaBeforeMuatate))
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate) t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
} }

View File

@@ -20,8 +20,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"k8s.io/apimachinery/pkg/util/diff" "github.com/google/go-cmp/cmp"
autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
@@ -163,7 +162,7 @@ func TestHorizontalPodAutoscalerAnnotations(t *testing.T) {
t.Fatalf("unexpected object: %v", obj) t.Fatalf("unexpected object: %v", obj)
} }
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) { if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
t.Errorf("diff: %v", diff.ObjectDiff(*hpa, hpaBeforeMuatate)) t.Errorf("diff: %v", cmp.Diff(*hpa, hpaBeforeMuatate))
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate) t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
} }

View File

@@ -21,9 +21,9 @@ import (
"testing" "testing"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
autoscalingv2 "k8s.io/api/autoscaling/v2beta2" autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -293,7 +293,7 @@ func TestHorizontalPodAutoscalerAnnotations(t *testing.T) {
t.Fatalf("unexpected object: %v", obj) t.Fatalf("unexpected object: %v", obj)
} }
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) { if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
t.Errorf("diff: %v", diff.ObjectDiff(*hpa, hpaBeforeMuatate)) t.Errorf("diff: %v", cmp.Diff(*hpa, hpaBeforeMuatate))
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate) t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
} }

View File

@@ -23,10 +23,10 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation" apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
utilvalidation "k8s.io/apimachinery/pkg/util/validation" utilvalidation "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
@@ -383,7 +383,7 @@ func validateCertificateSigningRequestUpdate(newCSR, oldCSR *certificates.Certif
case len(newConditions) > len(oldConditions): case len(newConditions) > len(oldConditions):
validationErrorList = append(validationErrorList, field.Forbidden(field.NewPath("status", "conditions"), fmt.Sprintf("updates may not add a condition of type %q", t))) validationErrorList = append(validationErrorList, field.Forbidden(field.NewPath("status", "conditions"), fmt.Sprintf("updates may not add a condition of type %q", t)))
case !apiequality.Semantic.DeepEqual(oldConditions, newConditions): case !apiequality.Semantic.DeepEqual(oldConditions, newConditions):
conditionDiff := diff.ObjectDiff(oldConditions, newConditions) conditionDiff := cmp.Diff(oldConditions, newConditions)
validationErrorList = append(validationErrorList, field.Forbidden(field.NewPath("status", "conditions"), fmt.Sprintf("updates may not modify a condition of type %q\n%v", t, conditionDiff))) validationErrorList = append(validationErrorList, field.Forbidden(field.NewPath("status", "conditions"), fmt.Sprintf("updates may not modify a condition of type %q\n%v", t, conditionDiff)))
} }
} }

View File

@@ -20,11 +20,11 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/apis/rbac/v1" v1 "k8s.io/kubernetes/pkg/apis/rbac/v1"
// install RBAC types // install RBAC types
_ "k8s.io/kubernetes/pkg/apis/rbac/install" _ "k8s.io/kubernetes/pkg/apis/rbac/install"
@@ -65,7 +65,7 @@ func TestHelpersRoundTrip(t *testing.T) {
continue continue
} }
if !reflect.DeepEqual(internalObj, roundTrippedObj) { if !reflect.DeepEqual(internalObj, roundTrippedObj) {
t.Errorf("err on %T: got difference:\n%s", internalObj, diff.ObjectDiff(internalObj, roundTrippedObj)) t.Errorf("err on %T: got difference:\n%s", internalObj, cmp.Diff(internalObj, roundTrippedObj))
continue continue
} }
} }

View File

@@ -20,12 +20,12 @@ import (
"context" "context"
"testing" "testing"
"github.com/google/go-cmp/cmp"
rbacv1 "k8s.io/api/rbac/v1" rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/equality" "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/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/yaml" "k8s.io/apimachinery/pkg/util/yaml"
rbacv1ac "k8s.io/client-go/applyconfigurations/rbac/v1" rbacv1ac "k8s.io/client-go/applyconfigurations/rbac/v1"
fakeclient "k8s.io/client-go/kubernetes/fake" fakeclient "k8s.io/client-go/kubernetes/fake"
@@ -215,7 +215,7 @@ func TestSyncClusterRole(t *testing.T) {
t.Fatalf("error unmarshalling apply request: %v", err) t.Fatalf("error unmarshalling apply request: %v", err)
} }
if !equality.Semantic.DeepEqual(ac, test.expectedClusterRoleApply) { if !equality.Semantic.DeepEqual(ac, test.expectedClusterRoleApply) {
t.Fatalf("%v", diff.ObjectDiff(test.expectedClusterRoleApply, ac)) t.Fatalf("%v", cmp.Diff(test.expectedClusterRoleApply, ac))
} }
if expectedActions == 2 { if expectedActions == 2 {
action := fakeClient.Actions()[1] action := fakeClient.Actions()[1]
@@ -227,7 +227,7 @@ func TestSyncClusterRole(t *testing.T) {
t.Fatalf("unexpected action %#v", action) t.Fatalf("unexpected action %#v", action)
} }
if !equality.Semantic.DeepEqual(updateAction.GetObject().(*rbacv1.ClusterRole), test.expectedClusterRole) { if !equality.Semantic.DeepEqual(updateAction.GetObject().(*rbacv1.ClusterRole), test.expectedClusterRole) {
t.Fatalf("%v", diff.ObjectDiff(test.expectedClusterRole, updateAction.GetObject().(*rbacv1.ClusterRole))) t.Fatalf("%v", cmp.Diff(test.expectedClusterRole, updateAction.GetObject().(*rbacv1.ClusterRole)))
} }
} }
}) })

View File

@@ -33,7 +33,6 @@ import (
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"
appsinformers "k8s.io/client-go/informers/apps/v1" appsinformers "k8s.io/client-go/informers/apps/v1"
coordinformers "k8s.io/client-go/informers/coordination/v1" coordinformers "k8s.io/client-go/informers/coordination/v1"
@@ -1250,10 +1249,10 @@ func TestMonitorNodeHealthUpdateStatus(t *testing.T) {
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 && !apiequality.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, cmp.Diff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
} }
if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !apiequality.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, cmp.Diff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
} }
podStatusUpdated := false podStatusUpdated := false
@@ -1800,10 +1799,10 @@ func TestMonitorNodeHealthUpdateNodeAndPodStatusWithLease(t *testing.T) {
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 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) { if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) {
t.Errorf("unexpected nodes: %s", diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0])) t.Errorf("unexpected nodes: %s", cmp.Diff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
} }
if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) { if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) {
t.Errorf("unexpected nodes: %s", diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0])) t.Errorf("unexpected nodes: %s", cmp.Diff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
} }
podStatusUpdated := false podStatusUpdated := false

View File

@@ -20,17 +20,18 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"k8s.io/klog/v2"
"reflect" "reflect"
"strconv" "strconv"
"sync" "sync"
"github.com/google/go-cmp/cmp"
"k8s.io/klog/v2"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
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"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
core "k8s.io/client-go/testing" core "k8s.io/client-go/testing"
@@ -349,7 +350,7 @@ func (r *VolumeReactor) CheckVolumes(expectedVolumes []*v1.PersistentVolume) err
if !reflect.DeepEqual(expectedMap, gotMap) { if !reflect.DeepEqual(expectedMap, gotMap) {
// Print ugly but useful diff of expected and received objects for // Print ugly but useful diff of expected and received objects for
// easier debugging. // easier debugging.
return fmt.Errorf("Volume check failed [A-expected, B-got]: %s", diff.ObjectDiff(expectedMap, gotMap)) return fmt.Errorf("Volume check failed [A-expected, B-got]: %s", cmp.Diff(expectedMap, gotMap))
} }
return nil return nil
} }
@@ -378,7 +379,7 @@ func (r *VolumeReactor) CheckClaims(expectedClaims []*v1.PersistentVolumeClaim)
if !reflect.DeepEqual(expectedMap, gotMap) { if !reflect.DeepEqual(expectedMap, gotMap) {
// Print ugly but useful diff of expected and received objects for // Print ugly but useful diff of expected and received objects for
// easier debugging. // easier debugging.
return fmt.Errorf("Claim check failed [A-expected, B-got result]: %s", diff.ObjectDiff(expectedMap, gotMap)) return fmt.Errorf("Claim check failed [A-expected, B-got result]: %s", cmp.Diff(expectedMap, gotMap))
} }
return nil return nil
} }

View File

@@ -25,11 +25,11 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
certificatesv1 "k8s.io/api/certificates/v1" certificatesv1 "k8s.io/api/certificates/v1"
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"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
certificatesclient "k8s.io/client-go/kubernetes/typed/certificates/v1beta1" certificatesclient "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
@@ -278,10 +278,10 @@ users:
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(certConfig, test.expectedCertConfig) { if !reflect.DeepEqual(certConfig, test.expectedCertConfig) {
t.Errorf("Unexpected certConfig: %s", diff.ObjectDiff(certConfig, test.expectedCertConfig)) t.Errorf("Unexpected certConfig: %s", cmp.Diff(certConfig, test.expectedCertConfig))
} }
if !reflect.DeepEqual(clientConfig, test.expectedClientConfig) { if !reflect.DeepEqual(clientConfig, test.expectedClientConfig) {
t.Errorf("Unexpected clientConfig: %s", diff.ObjectDiff(clientConfig, test.expectedClientConfig)) t.Errorf("Unexpected clientConfig: %s", cmp.Diff(clientConfig, test.expectedClientConfig))
} }
}) })
} }
@@ -341,7 +341,7 @@ users:
} }
if !reflect.DeepEqual(config, expectedConfig) { if !reflect.DeepEqual(config, expectedConfig) {
t.Errorf("Unexpected config: %s", diff.ObjectDiff(config, expectedConfig)) t.Errorf("Unexpected config: %s", cmp.Diff(config, expectedConfig))
} }
} }

View File

@@ -25,8 +25,7 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/apimachinery/pkg/util/diff" "github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"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"
@@ -633,7 +632,7 @@ func TestAddAllocatableThresholds(t *testing.T) {
for testName, testCase := range testCases { for testName, testCase := range testCases {
t.Run(testName, func(t *testing.T) { t.Run(testName, func(t *testing.T) {
if !thresholdsEqual(testCase.expected, addAllocatableThresholds(testCase.thresholds)) { if !thresholdsEqual(testCase.expected, addAllocatableThresholds(testCase.thresholds)) {
t.Errorf("Err not as expected, test: %v, Unexpected data: %s", testName, diff.ObjectDiff(testCase.expected, addAllocatableThresholds(testCase.thresholds))) t.Errorf("Err not as expected, test: %v, Unexpected data: %s", testName, cmp.Diff(testCase.expected, addAllocatableThresholds(testCase.thresholds)))
} }
}) })
} }

View File

@@ -33,13 +33,13 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
cadvisorapi "github.com/google/cadvisor/info/v1" cadvisorapi "github.com/google/cadvisor/info/v1"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/rand" "k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"
@@ -310,7 +310,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type, assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
"NotReady should be last") "NotReady should be last")
assert.Len(t, updatedNode.Status.Images, len(expectedImageList)) assert.Len(t, updatedNode.Status.Images, len(expectedImageList))
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode)) assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
}) })
} }
} }
@@ -504,7 +504,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
// Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961 // Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type, assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
"NodeReady should be the last condition") "NodeReady should be the last condition")
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode)) assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
} }
func TestUpdateExistingNodeStatusTimeout(t *testing.T) { func TestUpdateExistingNodeStatusTimeout(t *testing.T) {
@@ -714,7 +714,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
LastHeartbeatTime: metav1.Time{}, LastHeartbeatTime: metav1.Time{},
LastTransitionTime: metav1.Time{}, LastTransitionTime: metav1.Time{},
} }
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode)) assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
} }
// TODO(random-liu): Refactor the unit test to be table driven test. // TODO(random-liu): Refactor the unit test to be table driven test.
@@ -931,7 +931,7 @@ func TestUpdateNodeStatusWithLease(t *testing.T) {
cond.LastHeartbeatTime = cond.LastHeartbeatTime.Rfc3339Copy() cond.LastHeartbeatTime = cond.LastHeartbeatTime.Rfc3339Copy()
cond.LastTransitionTime = cond.LastTransitionTime.Rfc3339Copy() cond.LastTransitionTime = cond.LastTransitionTime.Rfc3339Copy()
} }
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode)) assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
// Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961 // Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type, assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
@@ -960,7 +960,7 @@ func TestUpdateNodeStatusWithLease(t *testing.T) {
for i, cond := range expectedNode.Status.Conditions { for i, cond := range expectedNode.Status.Conditions {
expectedNode.Status.Conditions[i].LastHeartbeatTime = metav1.NewTime(cond.LastHeartbeatTime.Time.Add(time.Minute)).Rfc3339Copy() expectedNode.Status.Conditions[i].LastHeartbeatTime = metav1.NewTime(cond.LastHeartbeatTime.Time.Add(time.Minute)).Rfc3339Copy()
} }
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode)) assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
// Update node status again when nothing is changed (except heartbeat time). // Update node status again when nothing is changed (except heartbeat time).
// Do not report node status if it is within the duration of nodeStatusReportFrequency. // Do not report node status if it is within the duration of nodeStatusReportFrequency.
@@ -1122,14 +1122,14 @@ func TestUpdateNodeStatusAndVolumesInUseWithNodeLease(t *testing.T) {
updatedNode, err := applyNodeStatusPatch(tc.existingNode, patchAction.GetPatch()) updatedNode, err := applyNodeStatusPatch(tc.existingNode, patchAction.GetPatch())
require.NoError(t, err) require.NoError(t, err)
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectedNode, updatedNode), "%s", diff.ObjectDiff(tc.expectedNode, updatedNode)) assert.True(t, apiequality.Semantic.DeepEqual(tc.expectedNode, updatedNode), "%s", cmp.Diff(tc.expectedNode, updatedNode))
} else { } else {
assert.Len(t, actions, 1) assert.Len(t, actions, 1)
assert.IsType(t, core.GetActionImpl{}, actions[0]) assert.IsType(t, core.GetActionImpl{}, actions[0])
} }
reportedInUse := fakeVolumeManager.GetVolumesReportedInUse() reportedInUse := fakeVolumeManager.GetVolumesReportedInUse()
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectedReportedInUse, reportedInUse), "%s", diff.ObjectDiff(tc.expectedReportedInUse, reportedInUse)) assert.True(t, apiequality.Semantic.DeepEqual(tc.expectedReportedInUse, reportedInUse), "%s", cmp.Diff(tc.expectedReportedInUse, reportedInUse))
}) })
} }
} }
@@ -1572,7 +1572,7 @@ func TestUpdateNewNodeStatusTooLargeReservation(t *testing.T) {
updatedNode, err := applyNodeStatusPatch(&existingNode, actions[1].(core.PatchActionImpl).GetPatch()) updatedNode, err := applyNodeStatusPatch(&existingNode, actions[1].(core.PatchActionImpl).GetPatch())
assert.NoError(t, err) assert.NoError(t, err)
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode.Status.Allocatable, updatedNode.Status.Allocatable), "%s", diff.ObjectDiff(expectedNode.Status.Allocatable, updatedNode.Status.Allocatable)) assert.True(t, apiequality.Semantic.DeepEqual(expectedNode.Status.Allocatable, updatedNode.Status.Allocatable), "%s", cmp.Diff(expectedNode.Status.Allocatable, updatedNode.Status.Allocatable))
} }
func TestUpdateDefaultLabels(t *testing.T) { func TestUpdateDefaultLabels(t *testing.T) {
@@ -2857,8 +2857,8 @@ func TestNodeStatusHasChanged(t *testing.T) {
statusCopy := tc.status.DeepCopy() statusCopy := tc.status.DeepCopy()
changed := nodeStatusHasChanged(tc.originalStatus, tc.status) changed := nodeStatusHasChanged(tc.originalStatus, tc.status)
assert.Equal(t, tc.expectChange, changed, "Expect node status change to be %t, but got %t.", tc.expectChange, changed) assert.Equal(t, tc.expectChange, changed, "Expect node status change to be %t, but got %t.", tc.expectChange, changed)
assert.True(t, apiequality.Semantic.DeepEqual(originalStatusCopy, tc.originalStatus), "%s", diff.ObjectDiff(originalStatusCopy, tc.originalStatus)) assert.True(t, apiequality.Semantic.DeepEqual(originalStatusCopy, tc.originalStatus), "%s", cmp.Diff(originalStatusCopy, tc.originalStatus))
assert.True(t, apiequality.Semantic.DeepEqual(statusCopy, tc.status), "%s", diff.ObjectDiff(statusCopy, tc.status)) assert.True(t, apiequality.Semantic.DeepEqual(statusCopy, tc.status), "%s", cmp.Diff(statusCopy, tc.status))
}) })
} }
} }
@@ -3012,7 +3012,7 @@ func TestUpdateNodeAddresses(t *testing.T) {
updatedNode, err := applyNodeStatusPatch(oldNode, patchAction.GetPatch()) updatedNode, err := applyNodeStatusPatch(oldNode, patchAction.GetPatch())
require.NoError(t, err) require.NoError(t, err)
assert.True(t, apiequality.Semantic.DeepEqual(updatedNode, expectedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode)) assert.True(t, apiequality.Semantic.DeepEqual(updatedNode, expectedNode), "%s", cmp.Diff(expectedNode, updatedNode))
}) })
} }
} }

View File

@@ -27,12 +27,12 @@ import (
"time" "time"
cadvisorapiv1 "github.com/google/cadvisor/info/v1" cadvisorapiv1 "github.com/google/cadvisor/info/v1"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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/util/diff"
"k8s.io/apimachinery/pkg/util/rand" "k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"
cloudprovider "k8s.io/cloud-provider" cloudprovider "k8s.io/cloud-provider"
@@ -579,10 +579,10 @@ func TestNodeAddress(t *testing.T) {
} }
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAddresses, existingNode.Status.Addresses), assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAddresses, existingNode.Status.Addresses),
"Diff: %s", diff.ObjectDiff(testCase.expectedAddresses, existingNode.Status.Addresses)) "Diff: %s", cmp.Diff(testCase.expectedAddresses, existingNode.Status.Addresses))
if testCase.expectedAnnotations != nil { if testCase.expectedAnnotations != nil {
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAnnotations, existingNode.Annotations), assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAnnotations, existingNode.Annotations),
"Diff: %s", diff.ObjectDiff(testCase.expectedAnnotations, existingNode.Annotations)) "Diff: %s", cmp.Diff(testCase.expectedAnnotations, existingNode.Annotations))
} }
}) })
} }
@@ -667,7 +667,7 @@ func TestNodeAddress_NoCloudProvider(t *testing.T) {
} }
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAddresses, existingNode.Status.Addresses), assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAddresses, existingNode.Status.Addresses),
"Diff: %s", diff.ObjectDiff(testCase.expectedAddresses, existingNode.Status.Addresses)) "Diff: %s", cmp.Diff(testCase.expectedAddresses, existingNode.Status.Addresses))
}) })
} }
} }
@@ -1149,7 +1149,7 @@ func TestMachineInfo(t *testing.T) {
} }
// check expected node // check expected node
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.node), assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.node),
"Diff: %s", diff.ObjectDiff(tc.expectNode, tc.node)) "Diff: %s", cmp.Diff(tc.expectNode, tc.node))
// check expected events // check expected events
require.Equal(t, len(tc.expectEvents), len(events)) require.Equal(t, len(tc.expectEvents), len(events))
for i := range tc.expectEvents { for i := range tc.expectEvents {
@@ -1239,7 +1239,7 @@ func TestVersionInfo(t *testing.T) {
require.Equal(t, tc.expectError, err) require.Equal(t, tc.expectError, err)
// check expected node // check expected node
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.node), assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.node),
"Diff: %s", diff.ObjectDiff(tc.expectNode, tc.node)) "Diff: %s", cmp.Diff(tc.expectNode, tc.node))
}) })
} }
} }
@@ -1319,7 +1319,7 @@ func TestImages(t *testing.T) {
expectNode.Status.Images = makeExpectedImageList(tc.imageList, tc.maxImages, MaxNamesPerImageInNodeStatus) expectNode.Status.Images = makeExpectedImageList(tc.imageList, tc.maxImages, MaxNamesPerImageInNodeStatus)
} }
assert.True(t, apiequality.Semantic.DeepEqual(expectNode, node), assert.True(t, apiequality.Semantic.DeepEqual(expectNode, node),
"Diff: %s", diff.ObjectDiff(expectNode, node)) "Diff: %s", cmp.Diff(expectNode, node))
}) })
} }
@@ -1510,7 +1510,7 @@ func TestReadyCondition(t *testing.T) {
} }
// check expected condition // check expected condition
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions), assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions)) "Diff: %s", cmp.Diff(tc.expectConditions, tc.node.Status.Conditions))
// check expected events // check expected events
require.Equal(t, len(tc.expectEvents), len(events)) require.Equal(t, len(tc.expectEvents), len(events))
for i := range tc.expectEvents { for i := range tc.expectEvents {
@@ -1632,7 +1632,7 @@ func TestMemoryPressureCondition(t *testing.T) {
} }
// check expected condition // check expected condition
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions), assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions)) "Diff: %s", cmp.Diff(tc.expectConditions, tc.node.Status.Conditions))
// check expected events // check expected events
require.Equal(t, len(tc.expectEvents), len(events)) require.Equal(t, len(tc.expectEvents), len(events))
for i := range tc.expectEvents { for i := range tc.expectEvents {
@@ -1754,7 +1754,7 @@ func TestPIDPressureCondition(t *testing.T) {
} }
// check expected condition // check expected condition
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions), assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions)) "Diff: %s", cmp.Diff(tc.expectConditions, tc.node.Status.Conditions))
// check expected events // check expected events
require.Equal(t, len(tc.expectEvents), len(events)) require.Equal(t, len(tc.expectEvents), len(events))
for i := range tc.expectEvents { for i := range tc.expectEvents {
@@ -1876,7 +1876,7 @@ func TestDiskPressureCondition(t *testing.T) {
} }
// check expected condition // check expected condition
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions), assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions)) "Diff: %s", cmp.Diff(tc.expectConditions, tc.node.Status.Conditions))
// check expected events // check expected events
require.Equal(t, len(tc.expectEvents), len(events)) require.Equal(t, len(tc.expectEvents), len(events))
for i := range tc.expectEvents { for i := range tc.expectEvents {
@@ -1933,7 +1933,7 @@ func TestVolumesInUse(t *testing.T) {
} }
// check expected volumes // check expected volumes
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectVolumesInUse, tc.node.Status.VolumesInUse), assert.True(t, apiequality.Semantic.DeepEqual(tc.expectVolumesInUse, tc.node.Status.VolumesInUse),
"Diff: %s", diff.ObjectDiff(tc.expectVolumesInUse, tc.node.Status.VolumesInUse)) "Diff: %s", cmp.Diff(tc.expectVolumesInUse, tc.node.Status.VolumesInUse))
}) })
} }
} }
@@ -1997,7 +1997,7 @@ func TestVolumeLimits(t *testing.T) {
} }
// check expected node // check expected node
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, node), assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, node),
"Diff: %s", diff.ObjectDiff(tc.expectNode, node)) "Diff: %s", cmp.Diff(tc.expectNode, node))
}) })
} }
} }

View File

@@ -27,10 +27,10 @@ import (
"time" "time"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/component-base/metrics/testutil" "k8s.io/component-base/metrics/testutil"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing" containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
@@ -101,7 +101,7 @@ func verifyEvents(t *testing.T, expected, actual []*PodLifecycleEvent) {
sort.Sort(sortableEvents(expected)) sort.Sort(sortableEvents(expected))
sort.Sort(sortableEvents(actual)) sort.Sort(sortableEvents(actual))
if !reflect.DeepEqual(expected, actual) { if !reflect.DeepEqual(expected, actual) {
t.Errorf("Actual events differ from the expected; diff:\n %v", diff.ObjectDiff(expected, actual)) t.Errorf("Actual events differ from the expected; diff:\n %v", cmp.Diff(expected, actual))
} }
} }

View File

@@ -25,6 +25,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/google/go-cmp/cmp"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
@@ -32,7 +33,6 @@ import (
"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"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog/v2" "k8s.io/klog/v2"
@@ -937,7 +937,7 @@ func (m *manager) needsReconcile(uid types.UID, status v1.PodStatus) bool {
} }
klog.V(3).InfoS("Pod status is inconsistent with cached status for pod, a reconciliation should be triggered", klog.V(3).InfoS("Pod status is inconsistent with cached status for pod, a reconciliation should be triggered",
"pod", klog.KObj(pod), "pod", klog.KObj(pod),
"statusDiff", diff.ObjectDiff(podStatus, &status)) "statusDiff", cmp.Diff(podStatus, &status))
return true return true
} }

View File

@@ -25,13 +25,13 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
@@ -242,7 +242,7 @@ func TestScaleGet(t *testing.T) {
} }
got := obj.(*autoscaling.Scale) got := obj.(*autoscaling.Scale)
if !apiequality.Semantic.DeepEqual(want, got) { if !apiequality.Semantic.DeepEqual(want, got) {
t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got)) t.Errorf("unexpected scale: %s", cmp.Diff(want, got))
} }
} }

View File

@@ -22,13 +22,13 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -297,7 +297,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)
} }
if !apiequality.Semantic.DeepEqual(got, want) { if !apiequality.Semantic.DeepEqual(got, want) {
t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want)) t.Errorf("unexpected scale: %s", cmp.Diff(got, want))
} }
} }

View File

@@ -22,13 +22,13 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -247,7 +247,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)
} }
if !apiequality.Semantic.DeepEqual(got, want) { if !apiequality.Semantic.DeepEqual(got, want) {
t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want)) t.Errorf("unexpected scale: %s", cmp.Diff(got, want))
} }
} }

View File

@@ -19,16 +19,17 @@ package storage
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
// Ensure that autoscaling/v1 package is initialized. // Ensure that autoscaling/v1 package is initialized.
_ "k8s.io/api/autoscaling/v1" _ "k8s.io/api/autoscaling/v1"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -211,6 +212,6 @@ func TestUpdateStatus(t *testing.T) {
autoscalerOut := obj.(*autoscaling.HorizontalPodAutoscaler) autoscalerOut := obj.(*autoscaling.HorizontalPodAutoscaler)
// 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 !apiequality.Semantic.DeepEqual(autoscalerIn.Status, autoscalerOut.Status) { if !apiequality.Semantic.DeepEqual(autoscalerIn.Status, autoscalerOut.Status) {
t.Errorf("unexpected object: %s", diff.ObjectDiff(autoscalerIn, autoscalerOut)) t.Errorf("unexpected object: %s", cmp.Diff(autoscalerIn, autoscalerOut))
} }
} }

View File

@@ -22,9 +22,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
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/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
certapi "k8s.io/kubernetes/pkg/apis/certificates" certapi "k8s.io/kubernetes/pkg/apis/certificates"
@@ -137,7 +137,7 @@ func TestStrategyCreate(t *testing.T) {
obj := tc.obj obj := tc.obj
Strategy.PrepareForCreate(tc.ctx, obj) Strategy.PrepareForCreate(tc.ctx, obj)
if !reflect.DeepEqual(obj, tc.expectedObj) { if !reflect.DeepEqual(obj, tc.expectedObj) {
t.Errorf("object diff: %s", diff.ObjectDiff(obj, tc.expectedObj)) t.Errorf("object diff: %s", cmp.Diff(obj, tc.expectedObj))
} }
}) })
} }
@@ -225,7 +225,7 @@ func TestStatusUpdate(t *testing.T) {
obj := tt.newObj.DeepCopy() obj := tt.newObj.DeepCopy()
StatusStrategy.PrepareForUpdate(context.TODO(), obj, tt.oldObj.DeepCopy()) StatusStrategy.PrepareForUpdate(context.TODO(), obj, tt.oldObj.DeepCopy())
if !reflect.DeepEqual(obj, tt.expectedObj) { if !reflect.DeepEqual(obj, tt.expectedObj) {
t.Errorf("object diff: %s", diff.ObjectDiff(obj, tt.expectedObj)) t.Errorf("object diff: %s", cmp.Diff(obj, tt.expectedObj))
} }
}) })
} }

View File

@@ -22,6 +22,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/google/go-cmp/cmp"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
@@ -30,7 +31,6 @@ import (
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/probe" "k8s.io/kubernetes/pkg/probe"
@@ -87,7 +87,7 @@ func TestList_NoError(t *testing.T) {
Items: []api.ComponentStatus{*(createTestStatus("test1", api.ConditionTrue, "ok", ""))}, Items: []api.ComponentStatus{*(createTestStatus("test1", api.ConditionTrue, "ok", ""))},
} }
if e, a := expect, got; !reflect.DeepEqual(e, a) { if e, a := expect, got; !reflect.DeepEqual(e, a) {
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
} }
} }
@@ -106,7 +106,7 @@ func TestList_WithLabelSelectors(t *testing.T) {
Items: []api.ComponentStatus{}, Items: []api.ComponentStatus{},
} }
if e, a := expect, got; !reflect.DeepEqual(e, a) { if e, a := expect, got; !reflect.DeepEqual(e, a) {
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
} }
} }
@@ -125,7 +125,7 @@ func TestList_WithFieldSelectors(t *testing.T) {
Items: []api.ComponentStatus{}, Items: []api.ComponentStatus{},
} }
if e, a := expect, got; !reflect.DeepEqual(e, a) { if e, a := expect, got; !reflect.DeepEqual(e, a) {
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
} }
} }
@@ -140,7 +140,7 @@ func TestList_FailedCheck(t *testing.T) {
*(createTestStatus("test1", api.ConditionFalse, "", ""))}, *(createTestStatus("test1", api.ConditionFalse, "", ""))},
} }
if e, a := expect, got; !reflect.DeepEqual(e, a) { if e, a := expect, got; !reflect.DeepEqual(e, a) {
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
} }
} }
@@ -155,7 +155,7 @@ func TestList_UnknownError(t *testing.T) {
*(createTestStatus("test1", api.ConditionUnknown, "", "fizzbuzz error"))}, *(createTestStatus("test1", api.ConditionUnknown, "", "fizzbuzz error"))},
} }
if e, a := expect, got; !reflect.DeepEqual(e, a) { if e, a := expect, got; !reflect.DeepEqual(e, a) {
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
} }
} }
@@ -167,7 +167,7 @@ func TestGet_NoError(t *testing.T) {
} }
expect := createTestStatus("test1", api.ConditionTrue, "ok", "") expect := createTestStatus("test1", api.ConditionTrue, "ok", "")
if e, a := expect, got; !reflect.DeepEqual(e, a) { if e, a := expect, got; !reflect.DeepEqual(e, a) {
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a)) t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
} }
} }

View File

@@ -21,9 +21,9 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
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/util/diff"
apitesting "k8s.io/kubernetes/pkg/api/testing" apitesting "k8s.io/kubernetes/pkg/api/testing"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
@@ -67,7 +67,7 @@ func TestGetAttrs(t *testing.T) {
"type": api.EventTypeNormal, "type": api.EventTypeNormal,
} }
if e, a := expectA, field; !reflect.DeepEqual(e, a) { if e, a := expectA, field; !reflect.DeepEqual(e, a) {
t.Errorf("diff: %s", diff.ObjectDiff(e, a)) t.Errorf("diff: %s", cmp.Diff(e, a))
} }
eventB := &api.Event{ eventB := &api.Event{
@@ -105,7 +105,7 @@ func TestGetAttrs(t *testing.T) {
"type": api.EventTypeNormal, "type": api.EventTypeNormal,
} }
if e, a := expectB, field; !reflect.DeepEqual(e, a) { if e, a := expectB, field; !reflect.DeepEqual(e, a) {
t.Errorf("diff: %s", diff.ObjectDiff(e, a)) t.Errorf("diff: %s", cmp.Diff(e, a))
} }
} }

View File

@@ -19,13 +19,13 @@ package storage
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -197,7 +197,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 !apiequality.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", cmp.Diff(pvIn.Status, pvOut.Status))
} }
} }

View File

@@ -20,13 +20,13 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -200,7 +200,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 !apiequality.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", cmp.Diff(pvc.Status, pvcOut.Status))
} }
} }

View File

@@ -25,6 +25,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
@@ -1074,7 +1075,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 !apiequality.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", cmp.Diff(podOut, podIn))
} }
} }
@@ -1147,7 +1148,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 !apiequality.Semantic.DeepEqual(podOut.Spec, podIn.Spec) || !apiequality.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", cmp.Diff(podOut, podIn))
} }
} }
@@ -1262,7 +1263,7 @@ func TestEtcdUpdateStatus(t *testing.T) {
if !apiequality.Semantic.DeepEqual(podOut.Spec, expected.Spec) || if !apiequality.Semantic.DeepEqual(podOut.Spec, expected.Spec) ||
!apiequality.Semantic.DeepEqual(podOut.Labels, expected.Labels) || !apiequality.Semantic.DeepEqual(podOut.Labels, expected.Labels) ||
!apiequality.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", cmp.Diff(podOut, expected))
} }
} }
} }

View File

@@ -22,13 +22,13 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -294,7 +294,7 @@ func TestScaleGet(t *testing.T) {
} }
got := obj.(*autoscaling.Scale) got := obj.(*autoscaling.Scale)
if !apiequality.Semantic.DeepEqual(want, got) { if !apiequality.Semantic.DeepEqual(want, got) {
t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got)) t.Errorf("unexpected scale: %s", cmp.Diff(want, got))
} }
} }

View File

@@ -19,12 +19,12 @@ package storage
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -206,7 +206,7 @@ func TestUpdateStatus(t *testing.T) {
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 !apiequality.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", cmp.Diff(resourcequotaIn, rqOut))
} }
} }

View File

@@ -23,9 +23,9 @@ import (
"sort" "sort"
"testing" "testing"
"github.com/google/go-cmp/cmp"
rbacv1 "k8s.io/api/rbac/v1" rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
) )
@@ -156,7 +156,7 @@ func TestDefaultRuleResolver(t *testing.T) {
sort.Sort(byHash(tc.effectiveRules)) sort.Sort(byHash(tc.effectiveRules))
if !reflect.DeepEqual(rules, tc.effectiveRules) { if !reflect.DeepEqual(rules, tc.effectiveRules) {
ruleDiff := diff.ObjectDiff(rules, tc.effectiveRules) ruleDiff := cmp.Diff(rules, tc.effectiveRules)
t.Errorf("case %d: %s", i, ruleDiff) t.Errorf("case %d: %s", i, ruleDiff)
} }
} }

View File

@@ -19,12 +19,12 @@ package storage
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -179,6 +179,6 @@ func TestUpdateStatus(t *testing.T) {
schedulingOut := obj.(*resource.PodSchedulingContext) schedulingOut := obj.(*resource.PodSchedulingContext)
// only compare relevant changes b/c of difference in metadata // only compare relevant changes b/c of difference in metadata
if !apiequality.Semantic.DeepEqual(schedulingCtx.Status, schedulingOut.Status) { if !apiequality.Semantic.DeepEqual(schedulingCtx.Status, schedulingOut.Status) {
t.Errorf("unexpected object: %s", diff.ObjectDiff(schedulingCtx.Status, schedulingOut.Status)) t.Errorf("unexpected object: %s", cmp.Diff(schedulingCtx.Status, schedulingOut.Status))
} }
} }

View File

@@ -19,12 +19,12 @@ package storage
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -177,6 +177,6 @@ func TestUpdateStatus(t *testing.T) {
claimOut := obj.(*resource.ResourceClaim) claimOut := obj.(*resource.ResourceClaim)
// only compare relevant changes b/c of difference in metadata // only compare relevant changes b/c of difference in metadata
if !apiequality.Semantic.DeepEqual(claim.Status, claimOut.Status) { if !apiequality.Semantic.DeepEqual(claim.Status, claimOut.Status) {
t.Errorf("unexpected object: %s", diff.ObjectDiff(claim.Status, claimOut.Status)) t.Errorf("unexpected object: %s", cmp.Diff(claim.Status, claimOut.Status))
} }
} }

View File

@@ -19,10 +19,10 @@ package csistoragecapacity
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/pkg/apis/storage" "k8s.io/kubernetes/pkg/apis/storage"
) )
@@ -80,7 +80,7 @@ func TestCSIStorageCapacityStrategy(t *testing.T) {
// Create with status should have kept status and all other fields. // Create with status should have kept status and all other fields.
if !apiequality.Semantic.DeepEqual(capacity, original) { if !apiequality.Semantic.DeepEqual(capacity, original) {
t.Errorf("unexpected objects difference after creation: %v", diff.ObjectDiff(original, capacity)) t.Errorf("unexpected objects difference after creation: %v", cmp.Diff(original, capacity))
} }
// Update of immutable fields is disallowed // Update of immutable fields is disallowed

View File

@@ -19,12 +19,12 @@ package storage
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
@@ -194,9 +194,9 @@ func TestEtcdStatusUpdate(t *testing.T) {
} }
attachmentOut := obj.(*storageapi.VolumeAttachment) attachmentOut := obj.(*storageapi.VolumeAttachment)
if !apiequality.Semantic.DeepEqual(attachmentIn.Spec, attachmentOut.Spec) { if !apiequality.Semantic.DeepEqual(attachmentIn.Spec, attachmentOut.Spec) {
t.Errorf("objects differ: %v", diff.ObjectDiff(attachmentOut.Spec, attachmentIn.Spec)) t.Errorf("objects differ: %v", cmp.Diff(attachmentOut.Spec, attachmentIn.Spec))
} }
if !apiequality.Semantic.DeepEqual(attachmentIn.Status, attachmentOut.Status) { if !apiequality.Semantic.DeepEqual(attachmentIn.Status, attachmentOut.Status) {
t.Errorf("objects differ: %v", diff.ObjectDiff(attachmentOut.Status, attachmentIn.Status)) t.Errorf("objects differ: %v", cmp.Diff(attachmentOut.Status, attachmentIn.Status))
} }
} }

View File

@@ -20,10 +20,10 @@ import (
"context" "context"
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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/util/diff"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/storage" "k8s.io/kubernetes/pkg/apis/storage"
@@ -90,7 +90,7 @@ func TestVolumeAttachmentStrategy(t *testing.T) {
statusVolumeAttachment.Status = storage.VolumeAttachmentStatus{Attached: true} statusVolumeAttachment.Status = storage.VolumeAttachmentStatus{Attached: true}
Strategy.PrepareForCreate(ctx, statusVolumeAttachment) Strategy.PrepareForCreate(ctx, statusVolumeAttachment)
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, volumeAttachment) { if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, volumeAttachment) {
t.Errorf("unexpected objects difference after creating with status: %v", diff.ObjectDiff(statusVolumeAttachment, volumeAttachment)) t.Errorf("unexpected objects difference after creating with status: %v", cmp.Diff(statusVolumeAttachment, volumeAttachment))
} }
// Update of spec is disallowed // Update of spec is disallowed
@@ -111,7 +111,7 @@ func TestVolumeAttachmentStrategy(t *testing.T) {
Strategy.PrepareForUpdate(ctx, statusVolumeAttachment, volumeAttachment) Strategy.PrepareForUpdate(ctx, statusVolumeAttachment, volumeAttachment)
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, volumeAttachment) { if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, volumeAttachment) {
t.Errorf("unexpected objects difference after modifying status: %v", diff.ObjectDiff(statusVolumeAttachment, volumeAttachment)) t.Errorf("unexpected objects difference after modifying status: %v", cmp.Diff(statusVolumeAttachment, volumeAttachment))
} }
} }
@@ -129,7 +129,7 @@ func TestVolumeAttachmentStrategySourceInlineSpec(t *testing.T) {
t.Errorf("InlineVolumeSpec unexpectedly set to nil during PrepareForCreate") t.Errorf("InlineVolumeSpec unexpectedly set to nil during PrepareForCreate")
} }
if !apiequality.Semantic.DeepEqual(volumeAttachmentSaved, volumeAttachment) { if !apiequality.Semantic.DeepEqual(volumeAttachmentSaved, volumeAttachment) {
t.Errorf("unexpected difference in object after creation: %v", diff.ObjectDiff(volumeAttachment, volumeAttachmentSaved)) t.Errorf("unexpected difference in object after creation: %v", cmp.Diff(volumeAttachment, volumeAttachmentSaved))
} }
Strategy.PrepareForUpdate(ctx, volumeAttachmentSaved, volumeAttachment) Strategy.PrepareForUpdate(ctx, volumeAttachmentSaved, volumeAttachment)
if volumeAttachmentSaved.Spec.Source.InlineVolumeSpec == nil { if volumeAttachmentSaved.Spec.Source.InlineVolumeSpec == nil {
@@ -157,7 +157,7 @@ func TestVolumeAttachmentStatusStrategy(t *testing.T) {
expectedVolumeAttachment := statusVolumeAttachment.DeepCopy() expectedVolumeAttachment := statusVolumeAttachment.DeepCopy()
StatusStrategy.PrepareForUpdate(ctx, statusVolumeAttachment, volumeAttachment) StatusStrategy.PrepareForUpdate(ctx, statusVolumeAttachment, volumeAttachment)
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, expectedVolumeAttachment) { if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, expectedVolumeAttachment) {
t.Errorf("unexpected objects difference after modifying status: %v", diff.ObjectDiff(statusVolumeAttachment, expectedVolumeAttachment)) t.Errorf("unexpected objects difference after modifying status: %v", cmp.Diff(statusVolumeAttachment, expectedVolumeAttachment))
} }
// spec and metadata modifications should be dropped // spec and metadata modifications should be dropped
@@ -175,7 +175,7 @@ func TestVolumeAttachmentStatusStrategy(t *testing.T) {
StatusStrategy.PrepareForUpdate(ctx, newVolumeAttachment, volumeAttachment) StatusStrategy.PrepareForUpdate(ctx, newVolumeAttachment, volumeAttachment)
if !apiequality.Semantic.DeepEqual(newVolumeAttachment, volumeAttachment) { if !apiequality.Semantic.DeepEqual(newVolumeAttachment, volumeAttachment) {
t.Errorf("unexpected objects difference after modifying spec: %v", diff.ObjectDiff(newVolumeAttachment, volumeAttachment)) t.Errorf("unexpected objects difference after modifying spec: %v", cmp.Diff(newVolumeAttachment, volumeAttachment))
} }
} }

View File

@@ -22,10 +22,10 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/google/gofuzz" "github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/diff"
) )
func TestLabelSelectorAsSelector(t *testing.T) { func TestLabelSelectorAsSelector(t *testing.T) {
@@ -211,7 +211,7 @@ func TestResetObjectMetaForStatus(t *testing.T) {
existingMeta.SetManagedFields(nil) existingMeta.SetManagedFields(nil)
if !reflect.DeepEqual(meta, existingMeta) { if !reflect.DeepEqual(meta, existingMeta) {
t.Error(diff.ObjectDiff(meta, existingMeta)) t.Error(cmp.Diff(meta, existingMeta))
} }
} }

View File

@@ -21,8 +21,8 @@ import (
"reflect" "reflect"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
) )
func TestPreferredVersionsAllGroups(t *testing.T) { func TestPreferredVersionsAllGroups(t *testing.T) {
@@ -124,7 +124,7 @@ func TestPreferredVersionsAllGroups(t *testing.T) {
for group, expected := range test.expectedPrioritized { for group, expected := range test.expectedPrioritized {
actual := scheme.PrioritizedVersionsForGroup(group) actual := scheme.PrioritizedVersionsForGroup(group)
if !reflect.DeepEqual(expected, actual) { if !reflect.DeepEqual(expected, actual) {
t.Error(diff.ObjectDiff(expected, actual)) t.Error(cmp.Diff(expected, actual))
} }
} }
@@ -134,7 +134,7 @@ func TestPreferredVersionsAllGroups(t *testing.T) {
actualPrioritizedAll[actual.Group] = append(actualPrioritizedAll[actual.Group], actual) actualPrioritizedAll[actual.Group] = append(actualPrioritizedAll[actual.Group], actual)
} }
if !reflect.DeepEqual(test.expectedPrioritized, actualPrioritizedAll) { if !reflect.DeepEqual(test.expectedPrioritized, actualPrioritizedAll) {
t.Error(diff.ObjectDiff(test.expectedPrioritized, actualPrioritizedAll)) t.Error(cmp.Diff(test.expectedPrioritized, actualPrioritizedAll))
} }
preferredAll := scheme.PreferredVersionAllGroups() preferredAll := scheme.PreferredVersionAllGroups()
@@ -143,7 +143,7 @@ func TestPreferredVersionsAllGroups(t *testing.T) {
actualPreferredAll[actual] = true actualPreferredAll[actual] = true
} }
if !reflect.DeepEqual(test.expectedPreferred, actualPreferredAll) { if !reflect.DeepEqual(test.expectedPreferred, actualPreferredAll) {
t.Error(diff.ObjectDiff(test.expectedPreferred, actualPreferredAll)) t.Error(cmp.Diff(test.expectedPreferred, actualPreferredAll))
} }
}) })
} }

View File

@@ -33,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/diff"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
@@ -128,7 +129,7 @@ func runTest(t *testing.T, source interface{}) {
return return
} }
if !semantic.DeepEqual(source, obj3) { if !semantic.DeepEqual(source, obj3) {
t.Errorf("3: %v: diff: %v", name, diff.ObjectDiff(source, obj3)) t.Errorf("3: %v: diff: %v", name, cmp.Diff(source, obj3))
return return
} }
} }

View File

@@ -19,11 +19,11 @@ package serializer
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/api/equality" "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"
"k8s.io/apimachinery/pkg/util/diff"
) )
type FakeV1Obj struct { type FakeV1Obj struct {
@@ -83,9 +83,9 @@ func TestSparse(t *testing.T) {
uncastDstObj2.(*FakeV2DifferentObj).TypeMeta = metav1.TypeMeta{} uncastDstObj2.(*FakeV2DifferentObj).TypeMeta = metav1.TypeMeta{}
if !equality.Semantic.DeepEqual(srcObj1, uncastDstObj1) { if !equality.Semantic.DeepEqual(srcObj1, uncastDstObj1) {
t.Fatal(diff.ObjectDiff(srcObj1, uncastDstObj1)) t.Fatal(cmp.Diff(srcObj1, uncastDstObj1))
} }
if !equality.Semantic.DeepEqual(srcObj2, uncastDstObj2) { if !equality.Semantic.DeepEqual(srcObj2, uncastDstObj2) {
t.Fatal(diff.ObjectDiff(srcObj2, uncastDstObj2)) t.Fatal(cmp.Diff(srcObj2, uncastDstObj2))
} }
} }

View File

@@ -20,6 +20,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
@@ -27,11 +28,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/apis/testapigroup" "k8s.io/apimachinery/pkg/apis/testapigroup"
"k8s.io/apimachinery/pkg/apis/testapigroup/v1" v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/diff"
) )
func TestIsList(t *testing.T) { func TestIsList(t *testing.T) {
@@ -283,7 +283,7 @@ func TestSetListToRuntimeObjectArray(t *testing.T) {
} }
for i := range list { for i := range list {
if e, a := list[i], pl.Items[i]; e != a { if e, a := list[i], pl.Items[i]; e != a {
t.Fatalf("%d: unmatched: %s", i, diff.ObjectDiff(e, a)) t.Fatalf("%d: unmatched: %s", i, cmp.Diff(e, a))
} }
} }
} }
@@ -304,7 +304,7 @@ func TestSetListToMatchingType(t *testing.T) {
} }
for i := range list { for i := range list {
if e, a := list[i], &pl.Items[i]; !reflect.DeepEqual(e, a) { if e, a := list[i], &pl.Items[i]; !reflect.DeepEqual(e, a) {
t.Fatalf("%d: unmatched: %s", i, diff.ObjectDiff(e, a)) t.Fatalf("%d: unmatched: %s", i, cmp.Diff(e, a))
} }
} }
} }

View File

@@ -23,12 +23,12 @@ import (
"strings" "strings"
"testing" "testing"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apiserver/pkg/apis/audit" "k8s.io/apiserver/pkg/apis/audit"
// import to call webhook's init() function to register audit.Policy to schema // import to call webhook's init() function to register audit.Policy to schema
_ "k8s.io/apiserver/plugin/pkg/audit/webhook" _ "k8s.io/apiserver/plugin/pkg/audit/webhook"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@@ -113,7 +113,7 @@ func TestParser(t *testing.T) {
assert.Len(t, policy.Rules, 3) // Sanity check. assert.Len(t, policy.Rules, 3) // Sanity check.
if !reflect.DeepEqual(policy, expectedPolicy) { if !reflect.DeepEqual(policy, expectedPolicy) {
t.Errorf("Unexpected policy! Diff:\n%s", diff.ObjectDiff(policy, expectedPolicy)) t.Errorf("Unexpected policy! Diff:\n%s", cmp.Diff(policy, expectedPolicy))
} }
} }

View File

@@ -38,6 +38,7 @@ import (
"time" "time"
"github.com/emicklei/go-restful/v3" "github.com/emicklei/go-restful/v3"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
@@ -2823,7 +2824,7 @@ func TestDeleteWithOptions(t *testing.T) {
} }
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{}) simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
if !apiequality.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", cmp.Diff(simpleStorage.deleteOptions, item))
} }
} }
@@ -2863,7 +2864,7 @@ func TestDeleteWithOptionsQuery(t *testing.T) {
} }
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{}) simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
if !apiequality.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", cmp.Diff(simpleStorage.deleteOptions, item))
} }
} }
@@ -2906,7 +2907,7 @@ func TestDeleteWithOptionsQueryAndBody(t *testing.T) {
} }
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{}) simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
if !apiequality.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", cmp.Diff(simpleStorage.deleteOptions, item))
} }
} }

View File

@@ -32,6 +32,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
@@ -41,7 +42,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming" "k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
example "k8s.io/apiserver/pkg/apis/example" example "k8s.io/apiserver/pkg/apis/example"
@@ -397,7 +397,7 @@ func TestWatchRead(t *testing.T) {
t.Fatalf("%s: Decode error: %v", name, err) t.Fatalf("%s: Decode error: %v", name, err)
} }
if e, a := object, gotObj; !apiequality.Semantic.DeepEqual(e, a) { if e, a := object, gotObj; !apiequality.Semantic.DeepEqual(e, a) {
t.Errorf("%s: different: %s", name, diff.ObjectDiff(e, a)) t.Errorf("%s: different: %s", name, cmp.Diff(e, a))
} }
} }
w.Stop() w.Stop()

View File

@@ -8,6 +8,7 @@ require (
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/evanphx/json-patch v4.12.0+incompatible github.com/evanphx/json-patch v4.12.0+incompatible
github.com/google/gnostic v0.5.7-v3refs github.com/google/gnostic v0.5.7-v3refs
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
github.com/spf13/cobra v1.6.0 github.com/spf13/cobra v1.6.0
@@ -36,7 +37,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect github.com/golang/protobuf v1.5.3 // indirect
github.com/google/btree v1.0.1 // indirect github.com/google/btree v1.0.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect github.com/google/gofuzz v1.1.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect

View File

@@ -21,10 +21,10 @@ import (
"reflect" "reflect"
"testing" "testing"
"k8s.io/api/core/v1" "github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
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/json" "k8s.io/apimachinery/pkg/util/json"
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"
) )
@@ -74,7 +74,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(testData, poutput) { if !reflect.DeepEqual(testData, poutput) {
t.Errorf("Test data and unmarshaled data are not equal: %v", diff.ObjectDiff(poutput, testData)) t.Errorf("Test data and unmarshaled data are not equal: %v", cmp.Diff(poutput, testData))
} }
obj := &v1.Pod{ obj := &v1.Pod{
@@ -97,7 +97,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(obj, &objOut) { if !reflect.DeepEqual(obj, &objOut) {
t.Errorf("Unexpected inequality:\n%v", diff.ObjectDiff(obj, &objOut)) t.Errorf("Unexpected inequality:\n%v", cmp.Diff(obj, &objOut))
} }
} }

View File

@@ -21,12 +21,12 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/api/equality" "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/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/dynamic/dynamicinformer" "k8s.io/client-go/dynamic/dynamicinformer"
"k8s.io/client-go/dynamic/fake" "k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
@@ -118,7 +118,7 @@ func TestFilteredDynamicSharedInformerFactory(t *testing.T) {
t.Errorf("informer received an object for namespace %s when watching namespace %s", ts.ns, ts.informNS) t.Errorf("informer received an object for namespace %s when watching namespace %s", ts.ns, ts.informNS)
} }
if !equality.Semantic.DeepEqual(testObject, objFromInformer) { if !equality.Semantic.DeepEqual(testObject, objFromInformer) {
t.Fatalf("%v", diff.ObjectDiff(testObject, objFromInformer)) t.Fatalf("%v", cmp.Diff(testObject, objFromInformer))
} }
case <-ctx.Done(): case <-ctx.Done():
if ts.ns == ts.informNS { if ts.ns == ts.informNS {
@@ -239,7 +239,7 @@ func TestDynamicSharedInformerFactory(t *testing.T) {
select { select {
case objFromInformer := <-informerReciveObjectCh: case objFromInformer := <-informerReciveObjectCh:
if !equality.Semantic.DeepEqual(testObject, objFromInformer) { if !equality.Semantic.DeepEqual(testObject, objFromInformer) {
t.Fatalf("%v", diff.ObjectDiff(testObject, objFromInformer)) t.Fatalf("%v", cmp.Diff(testObject, objFromInformer))
} }
case <-ctx.Done(): case <-ctx.Done():
t.Errorf("tested informer haven't received an object, waited %v", timeout) t.Errorf("tested informer haven't received an object, waited %v", timeout)

View File

@@ -20,11 +20,11 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/dynamic/dynamiclister" "k8s.io/client-go/dynamic/dynamiclister"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
) )
@@ -90,7 +90,7 @@ func TestNamespaceGetMethod(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(test.expectedObject, actualObject) { if !reflect.DeepEqual(test.expectedObject, actualObject) {
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, diff.ObjectDiff(test.expectedObject, actualObject)) t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, cmp.Diff(test.expectedObject, actualObject))
} }
}) })
} }
@@ -188,7 +188,7 @@ func TestListerGetMethod(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(test.expectedObject, actualObject) { if !reflect.DeepEqual(test.expectedObject, actualObject) {
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, diff.ObjectDiff(test.expectedObject, actualObject)) t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, cmp.Diff(test.expectedObject, actualObject))
} }
}) })
} }
@@ -245,7 +245,7 @@ func assertListOrDie(expected, actual []*unstructured.Unstructured, t *testing.T
for _, actualObject := range actual { for _, actualObject := range actual {
if actualObject.GetName() == expectedObject.GetName() { if actualObject.GetName() == expectedObject.GetName() {
if !reflect.DeepEqual(expectedObject, actualObject) { if !reflect.DeepEqual(expectedObject, actualObject) {
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", expectedObject, actualObject, diff.ObjectDiff(expectedObject, actualObject)) t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", expectedObject, actualObject, cmp.Diff(expectedObject, actualObject))
} }
found = true found = true
} }

View File

@@ -22,13 +22,13 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
"k8s.io/klog/v2" "k8s.io/klog/v2"
"k8s.io/apimachinery/pkg/api/equality" "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"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/metadata/fake" "k8s.io/client-go/metadata/fake"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
) )
@@ -147,7 +147,7 @@ func TestMetadataSharedInformerFactory(t *testing.T) {
select { select {
case objFromInformer := <-informerReciveObjectCh: case objFromInformer := <-informerReciveObjectCh:
if !equality.Semantic.DeepEqual(testObject, objFromInformer) { if !equality.Semantic.DeepEqual(testObject, objFromInformer) {
t.Fatalf("%v", diff.ObjectDiff(testObject, objFromInformer)) t.Fatalf("%v", cmp.Diff(testObject, objFromInformer))
} }
case <-ctx.Done(): case <-ctx.Done():
t.Errorf("tested informer haven't received an object, waited %v", timeout) t.Errorf("tested informer haven't received an object, waited %v", timeout)

View File

@@ -20,11 +20,11 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
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/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
) )
@@ -89,7 +89,7 @@ func TestNamespaceGetMethod(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(test.expectedObject, actualObject) { if !reflect.DeepEqual(test.expectedObject, actualObject) {
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, diff.ObjectDiff(test.expectedObject, actualObject)) t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, cmp.Diff(test.expectedObject, actualObject))
} }
}) })
} }
@@ -187,7 +187,7 @@ func TestListerGetMethod(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(test.expectedObject, actualObject) { if !reflect.DeepEqual(test.expectedObject, actualObject) {
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, diff.ObjectDiff(test.expectedObject, actualObject)) t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, cmp.Diff(test.expectedObject, actualObject))
} }
}) })
} }
@@ -231,7 +231,7 @@ func assertListOrDie(expected, actual []*metav1.PartialObjectMetadata, t *testin
for _, actualObject := range actual { for _, actualObject := range actual {
if actualObject.GetName() == expectedObject.GetName() { if actualObject.GetName() == expectedObject.GetName() {
if !reflect.DeepEqual(expectedObject, actualObject) { if !reflect.DeepEqual(expectedObject, actualObject) {
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", expectedObject, actualObject, diff.ObjectDiff(expectedObject, actualObject)) t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", expectedObject, actualObject, cmp.Diff(expectedObject, actualObject))
} }
found = true found = true
} }

View File

@@ -23,6 +23,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
coordinationv1 "k8s.io/api/coordination/v1" coordinationv1 "k8s.io/api/coordination/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
@@ -31,7 +32,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/diff"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
clienttesting "k8s.io/client-go/testing" clienttesting "k8s.io/client-go/testing"
@@ -205,7 +205,7 @@ func TestNewNodeLease(t *testing.T) {
t.Fatalf("the new lease must be newly allocated, but got same address as base") t.Fatalf("the new lease must be newly allocated, but got same address as base")
} }
if !apiequality.Semantic.DeepEqual(tc.expect, newLease) { if !apiequality.Semantic.DeepEqual(tc.expect, newLease) {
t.Errorf("unexpected result from newLease: %s", diff.ObjectDiff(tc.expect, newLease)) t.Errorf("unexpected result from newLease: %s", cmp.Diff(tc.expect, newLease))
} }
}) })
} }

View File

@@ -19,10 +19,10 @@ package reconciliation
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
rbacv1 "k8s.io/api/rbac/v1" rbacv1 "k8s.io/api/rbac/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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"
) )
func role(rules []rbacv1.PolicyRule, labels map[string]string, annotations map[string]string) *rbacv1.ClusterRole { func role(rules []rbacv1.PolicyRule, labels map[string]string, annotations map[string]string) *rbacv1.ClusterRole {
@@ -392,7 +392,7 @@ func TestComputeReconciledRoleAggregationRules(t *testing.T) {
continue continue
} }
if reconciliationNeeded && !apiequality.Semantic.DeepEqual(result.Role.(ClusterRoleRuleOwner).ClusterRole, tc.expectedReconciledRole) { if reconciliationNeeded && !apiequality.Semantic.DeepEqual(result.Role.(ClusterRoleRuleOwner).ClusterRole, tc.expectedReconciledRole) {
t.Errorf("%s: %v", k, diff.ObjectDiff(tc.expectedReconciledRole, result.Role.(ClusterRoleRuleOwner).ClusterRole)) t.Errorf("%s: %v", k, cmp.Diff(tc.expectedReconciledRole, result.Role.(ClusterRoleRuleOwner).ClusterRole))
} }
} }
} }

View File

@@ -8,6 +8,7 @@ require (
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/emicklei/go-restful/v3 v3.9.0 github.com/emicklei/go-restful/v3 v3.9.0
github.com/gogo/protobuf v1.3.2 github.com/gogo/protobuf v1.3.2
github.com/google/go-cmp v0.5.9
github.com/google/gofuzz v1.1.0 github.com/google/gofuzz v1.1.0
github.com/spf13/cobra v1.6.0 github.com/spf13/cobra v1.6.0
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
@@ -47,7 +48,6 @@ require (
github.com/golang/protobuf v1.5.3 // indirect github.com/golang/protobuf v1.5.3 // indirect
github.com/google/cel-go v0.12.6 // indirect github.com/google/cel-go v0.12.6 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect

View File

@@ -23,10 +23,10 @@ import (
"net/http/httputil" "net/http/httputil"
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" 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/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
@@ -327,7 +327,7 @@ func TestAPIs(t *testing.T) {
continue continue
} }
if !apiequality.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, cmp.Diff(tc.expected, actual))
continue continue
} }
} }
@@ -514,7 +514,7 @@ func TestAPIGroup(t *testing.T) {
continue continue
} }
if !apiequality.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, cmp.Diff(tc.expected, actual))
continue continue
} }
} }

View File

@@ -24,8 +24,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/google/go-cmp/cmp"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/cli-runtime/pkg/genericiooptions" "k8s.io/cli-runtime/pkg/genericiooptions"
"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"
@@ -896,7 +896,7 @@ func (test configCommandTest) run(t *testing.T) string {
testClearLocationOfOrigin(&actualConfig) testClearLocationOfOrigin(&actualConfig)
if !apiequality.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", cmp.Diff(test.expectedConfig, actualConfig))
t.Errorf("expected: %#v\n actual: %#v", test.expectedConfig, actualConfig) t.Errorf("expected: %#v\n actual: %#v", test.expectedConfig, actualConfig)
} }

View File

@@ -21,7 +21,7 @@ import (
"strings" "strings"
"testing" "testing"
"k8s.io/apimachinery/pkg/util/diff" "github.com/google/go-cmp/cmp"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api" clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
) )
@@ -102,7 +102,7 @@ func (test stepParserTest) run(t *testing.T) {
} }
if !reflect.DeepEqual(test.expectedNavigationSteps, *actualSteps) { if !reflect.DeepEqual(test.expectedNavigationSteps, *actualSteps) {
t.Errorf("diff: %v", diff.ObjectDiff(test.expectedNavigationSteps, *actualSteps)) t.Errorf("diff: %v", cmp.Diff(test.expectedNavigationSteps, *actualSteps))
t.Errorf("expected: %#v\n actual: %#v", test.expectedNavigationSteps, *actualSteps) t.Errorf("expected: %#v\n actual: %#v", test.expectedNavigationSteps, *actualSteps)
} }
} }

View File

@@ -22,6 +22,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
appsv1 "k8s.io/api/apps/v1" appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
@@ -29,7 +30,6 @@ import (
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"
"k8s.io/apimachinery/pkg/util/diff"
fakeexternal "k8s.io/client-go/kubernetes/fake" fakeexternal "k8s.io/client-go/kubernetes/fake"
testclient "k8s.io/client-go/testing" testclient "k8s.io/client-go/testing"
"k8s.io/kubectl/pkg/cmd/util/podcmd" "k8s.io/kubectl/pkg/cmd/util/podcmd"
@@ -422,7 +422,7 @@ func TestLogsForObject(t *testing.T) {
got := fakeClientset.Actions()[i] got := fakeClientset.Actions()[i]
want := test.actions[i] want := test.actions[i]
if !reflect.DeepEqual(got, want) { if !reflect.DeepEqual(got, want) {
t.Errorf("%s: unexpected diff for action: %s", test.name, diff.ObjectDiff(got, want)) t.Errorf("%s: unexpected diff for action: %s", test.name, cmp.Diff(got, want))
} }
} }
for i++; i < len(fakeClientset.Actions()); i++ { for i++; i < len(fakeClientset.Actions()); i++ {

View File

@@ -19,11 +19,11 @@ package scheme
import ( import (
"testing" "testing"
"k8s.io/api/batch/v1" "github.com/google/go-cmp/cmp"
v1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/api/equality" "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"
) )
func TestCronJob(t *testing.T) { func TestCronJob(t *testing.T) {
@@ -48,6 +48,6 @@ func TestCronJob(t *testing.T) {
uncastDst.(*v1.CronJob).TypeMeta = metav1.TypeMeta{} uncastDst.(*v1.CronJob).TypeMeta = metav1.TypeMeta{}
if !equality.Semantic.DeepEqual(src, uncastDst) { if !equality.Semantic.DeepEqual(src, uncastDst) {
t.Fatal(diff.ObjectDiff(src, uncastDst)) t.Fatal(cmp.Diff(src, uncastDst))
} }
} }