Replace uses of ObjectReflectDiff with cmp.Diff

ObjectReflectDiff 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:34:03 -07:00
parent 9627c50ef3
commit bc302fa414
56 changed files with 221 additions and 231 deletions

View File

@@ -23,11 +23,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
"github.com/spf13/pflag" "github.com/spf13/pflag"
eventv1 "k8s.io/api/events/v1" eventv1 "k8s.io/api/events/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
utilerrors "k8s.io/apimachinery/pkg/util/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors"
apiserveroptions "k8s.io/apiserver/pkg/server/options" apiserveroptions "k8s.io/apiserver/pkg/server/options"
cpconfig "k8s.io/cloud-provider/config" cpconfig "k8s.io/cloud-provider/config"
@@ -441,7 +441,7 @@ func TestAddFlags(t *testing.T) {
sort.Sort(sortedGCIgnoredResources(expected.GarbageCollectorController.GCIgnoredResources)) sort.Sort(sortedGCIgnoredResources(expected.GarbageCollectorController.GCIgnoredResources))
if !reflect.DeepEqual(expected, s) { if !reflect.DeepEqual(expected, s) {
t.Errorf("Got different run options than expected.\nDifference detected on:\n%s", diff.ObjectReflectDiff(expected, s)) t.Errorf("Got different run options than expected.\nDifference detected on:\n%s", cmp.Diff(expected, s))
} }
} }
@@ -640,7 +640,7 @@ func TestApplyTo(t *testing.T) {
s.ApplyTo(c) s.ApplyTo(c)
if !reflect.DeepEqual(expected.ComponentConfig, c.ComponentConfig) { if !reflect.DeepEqual(expected.ComponentConfig, c.ComponentConfig) {
t.Errorf("Got different configuration than expected.\nDifference detected on:\n%s", diff.ObjectReflectDiff(expected.ComponentConfig, c.ComponentConfig)) t.Errorf("Got different configuration than expected.\nDifference detected on:\n%s", cmp.Diff(expected.ComponentConfig, c.ComponentConfig))
} }
} }

View File

@@ -21,9 +21,9 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/diff"
cliflag "k8s.io/component-base/cli/flag" cliflag "k8s.io/component-base/cli/flag"
"k8s.io/kubernetes/pkg/kubelet/config" "k8s.io/kubernetes/pkg/kubelet/config"
) )
@@ -101,7 +101,7 @@ func TestRoundTrip(t *testing.T) {
continue continue
} }
if !reflect.DeepEqual(modifiedFlags, outputFlags) { if !reflect.DeepEqual(modifiedFlags, outputFlags) {
t.Errorf("%s: flags did not round trip: %s", testCase.name, diff.ObjectReflectDiff(modifiedFlags, outputFlags)) t.Errorf("%s: flags did not round trip: %s", testCase.name, cmp.Diff(modifiedFlags, outputFlags))
continue continue
} }
} }

View File

@@ -27,7 +27,6 @@ import (
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"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
@@ -2382,14 +2381,14 @@ func TestDropInPlacePodVerticalScaling(t *testing.T) {
// old pod should never be changed // old pod should never be changed
if !reflect.DeepEqual(oldPod, oldPodInfo.pod()) { if !reflect.DeepEqual(oldPod, oldPodInfo.pod()) {
t.Errorf("old pod changed: %v", diff.ObjectReflectDiff(oldPod, oldPodInfo.pod())) t.Errorf("old pod changed: %v", cmp.Diff(oldPod, oldPodInfo.pod()))
} }
switch { switch {
case enabled || oldPodHasInPlaceVerticalScaling: case enabled || oldPodHasInPlaceVerticalScaling:
// new pod shouldn't change if feature enabled or if old pod has ResizePolicy set // new pod shouldn't change if feature enabled or if old pod has ResizePolicy set
if !reflect.DeepEqual(newPod, newPodInfo.pod()) { if !reflect.DeepEqual(newPod, newPodInfo.pod()) {
t.Errorf("new pod changed: %v", diff.ObjectReflectDiff(newPod, newPodInfo.pod())) t.Errorf("new pod changed: %v", cmp.Diff(newPod, newPodInfo.pod()))
} }
case newPodHasInPlaceVerticalScaling: case newPodHasInPlaceVerticalScaling:
// new pod should be changed // new pod should be changed
@@ -2398,12 +2397,12 @@ func TestDropInPlacePodVerticalScaling(t *testing.T) {
} }
// new pod should not have ResizePolicy // new pod should not have ResizePolicy
if !reflect.DeepEqual(newPod, podWithoutInPlaceVerticalScaling()) { if !reflect.DeepEqual(newPod, podWithoutInPlaceVerticalScaling()) {
t.Errorf("new pod has ResizePolicy: %v", diff.ObjectReflectDiff(newPod, podWithoutInPlaceVerticalScaling())) t.Errorf("new pod has ResizePolicy: %v", cmp.Diff(newPod, podWithoutInPlaceVerticalScaling()))
} }
default: default:
// new pod should not need to be changed // new pod should not need to be changed
if !reflect.DeepEqual(newPod, newPodInfo.pod()) { if !reflect.DeepEqual(newPod, newPodInfo.pod()) {
t.Errorf("new pod changed: %v", diff.ObjectReflectDiff(newPod, newPodInfo.pod())) t.Errorf("new pod changed: %v", cmp.Diff(newPod, newPodInfo.pod()))
} }
} }
}) })

View File

@@ -28,7 +28,6 @@ import (
"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/intstr" "k8s.io/apimachinery/pkg/util/intstr"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
featuregatetesting "k8s.io/component-base/featuregate/testing" featuregatetesting "k8s.io/component-base/featuregate/testing"
@@ -181,7 +180,7 @@ func testWorkloadDefaults(t *testing.T, featuresEnabled bool) {
defaults := detectDefaults(t, rc, reflect.ValueOf(template)) defaults := detectDefaults(t, rc, reflect.ValueOf(template))
if !reflect.DeepEqual(expectedDefaults, defaults) { if !reflect.DeepEqual(expectedDefaults, defaults) {
t.Errorf("Defaults for PodTemplateSpec changed. This can cause spurious rollouts of workloads on API server upgrade.") t.Errorf("Defaults for PodTemplateSpec changed. This can cause spurious rollouts of workloads on API server upgrade.")
t.Logf(diff.ObjectReflectDiff(expectedDefaults, defaults)) t.Logf(cmp.Diff(expectedDefaults, defaults))
} }
} }
@@ -327,7 +326,7 @@ func testPodDefaults(t *testing.T, featuresEnabled bool) {
defaults := detectDefaults(t, pod, reflect.ValueOf(pod)) defaults := detectDefaults(t, pod, reflect.ValueOf(pod))
if !reflect.DeepEqual(expectedDefaults, defaults) { if !reflect.DeepEqual(expectedDefaults, defaults) {
t.Errorf("Defaults for PodSpec changed. This can cause spurious restarts of containers on API server upgrade.") t.Errorf("Defaults for PodSpec changed. This can cause spurious restarts of containers on API server upgrade.")
t.Logf(diff.ObjectReflectDiff(expectedDefaults, defaults)) t.Logf(cmp.Diff(expectedDefaults, defaults))
} }
} }

View File

@@ -26,11 +26,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" 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/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"
@@ -1070,7 +1070,7 @@ func TestSyncEndpointsHeadlessService(t *testing.T) {
}}, }},
}) })
if !reflect.DeepEqual(originalService, service) { if !reflect.DeepEqual(originalService, service) {
t.Fatalf("syncing endpoints changed service: %s", diff.ObjectReflectDiff(service, originalService)) t.Fatalf("syncing endpoints changed service: %s", cmp.Diff(service, originalService))
} }
endpointsHandler.ValidateRequestCount(t, 1) endpointsHandler.ValidateRequestCount(t, 1)
endpointsHandler.ValidateRequest(t, "/api/v1/namespaces/"+ns+"/endpoints/foo", "PUT", &data) endpointsHandler.ValidateRequest(t, "/api/v1/namespaces/"+ns+"/endpoints/foo", "PUT", &data)

View File

@@ -21,13 +21,13 @@ import (
"testing" "testing"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1" corev1 "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/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/authentication/request/headerrequest" "k8s.io/apiserver/pkg/authentication/request/headerrequest"
"k8s.io/apiserver/pkg/server/dynamiccertificates" "k8s.io/apiserver/pkg/server/dynamiccertificates"
@@ -298,7 +298,7 @@ func TestWriteClientCAs(t *testing.T) {
actualConfigMaps, updated := getFinalConfigMaps(t, client) actualConfigMaps, updated := getFinalConfigMaps(t, client)
if !reflect.DeepEqual(test.expectedConfigMaps, actualConfigMaps) { if !reflect.DeepEqual(test.expectedConfigMaps, actualConfigMaps) {
t.Fatalf("%s: %v", test.name, diff.ObjectReflectDiff(test.expectedConfigMaps, actualConfigMaps)) t.Fatalf("%s: %v", test.name, cmp.Diff(test.expectedConfigMaps, actualConfigMaps))
} }
if test.expectCreate != updated { if test.expectCreate != updated {
t.Fatalf("%s: expected %v, got %v", test.name, test.expectCreate, updated) t.Fatalf("%s: expected %v, got %v", test.name, test.expectCreate, updated)

View File

@@ -21,7 +21,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"k8s.io/apimachinery/pkg/util/diff" "github.com/google/go-cmp/cmp"
"k8s.io/kube-openapi/pkg/common" "k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/handler" "k8s.io/kube-openapi/pkg/handler"
"k8s.io/kube-openapi/pkg/validation/spec" "k8s.io/kube-openapi/pkg/validation/spec"
@@ -52,7 +52,7 @@ func TestOpenAPIRoundtrip(t *testing.T) {
delete(value.Schema.Extensions, common.ExtensionV2Schema) delete(value.Schema.Extensions, common.ExtensionV2Schema)
if !reflect.DeepEqual(value.Schema, roundTripped) { if !reflect.DeepEqual(value.Schema, roundTripped) {
t.Errorf("unexpected diff (a=expected,b=roundtripped):\n%s", diff.ObjectReflectDiff(value.Schema, roundTripped)) t.Errorf("unexpected diff (a=expected,b=roundtripped):\n%s", cmp.Diff(value.Schema, roundTripped))
return return
} }
}) })

View File

@@ -22,8 +22,8 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/api/core/v1" "github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/util/diff" v1 "k8s.io/api/core/v1"
"k8s.io/cloud-provider/fake" "k8s.io/cloud-provider/fake"
) )
@@ -54,7 +54,7 @@ func TestNodeAddressesDelay(t *testing.T) {
t.Errorf("Unexpected err: %q\n", err) t.Errorf("Unexpected err: %q\n", err)
} }
if !reflect.DeepEqual(nodeAddresses, cloud.Addresses) { if !reflect.DeepEqual(nodeAddresses, cloud.Addresses) {
t.Errorf("Unexpected diff of node addresses: %v", diff.ObjectReflectDiff(nodeAddresses, cloud.Addresses)) t.Errorf("Unexpected diff of node addresses: %v", cmp.Diff(nodeAddresses, cloud.Addresses))
} }
// Change the IP address // Change the IP address
@@ -140,7 +140,7 @@ func TestNodeAddressesUsesLastSuccess(t *testing.T) {
t.Errorf("unexpected err: %v", err) t.Errorf("unexpected err: %v", err)
} }
if got, want := nodeAddresses, test.wantAddrs; !reflect.DeepEqual(got, want) { if got, want := nodeAddresses, test.wantAddrs; !reflect.DeepEqual(got, want) {
t.Errorf("Unexpected diff of node addresses: %v", diff.ObjectReflectDiff(got, want)) t.Errorf("Unexpected diff of node addresses: %v", cmp.Diff(got, want))
} }
}) })
} }

View File

@@ -40,7 +40,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/diff"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
core "k8s.io/client-go/testing" core "k8s.io/client-go/testing"
"k8s.io/client-go/tools/record" "k8s.io/client-go/tools/record"
@@ -3273,7 +3272,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
expected.Conditions = append([]v1.PodCondition{test.expectedPodDisruptionCondition}, expected.Conditions...) expected.Conditions = append([]v1.PodCondition{test.expectedPodDisruptionCondition}, expected.Conditions...)
} }
if !apiequality.Semantic.DeepEqual(*expected, actual) { if !apiequality.Semantic.DeepEqual(*expected, actual) {
t.Fatalf("Unexpected status: %s", diff.ObjectReflectDiff(*expected, actual)) t.Fatalf("Unexpected status: %s", cmp.Diff(*expected, actual))
} }
}) })
} }

View File

@@ -35,7 +35,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"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
@@ -613,7 +612,7 @@ func TestTerminatePod(t *testing.T) {
expectUnknownState := v1.ContainerState{Terminated: &v1.ContainerStateTerminated{Reason: "ContainerStatusUnknown", Message: "The container could not be located when the pod was terminated", ExitCode: 137}} expectUnknownState := v1.ContainerState{Terminated: &v1.ContainerStateTerminated{Reason: "ContainerStatusUnknown", Message: "The container could not be located when the pod was terminated", ExitCode: 137}}
if !reflect.DeepEqual(newStatus.InitContainerStatuses[0].State, expectUnknownState) { if !reflect.DeepEqual(newStatus.InitContainerStatuses[0].State, expectUnknownState) {
t.Errorf("terminated container state not defaulted: %s", diff.ObjectReflectDiff(newStatus.InitContainerStatuses[0].State, expectUnknownState)) t.Errorf("terminated container state not defaulted: %s", cmp.Diff(newStatus.InitContainerStatuses[0].State, expectUnknownState))
} }
if !reflect.DeepEqual(newStatus.InitContainerStatuses[1].State, firstStatus.InitContainerStatuses[1].State) { if !reflect.DeepEqual(newStatus.InitContainerStatuses[1].State, firstStatus.InitContainerStatuses[1].State) {
t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses) t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses)
@@ -622,7 +621,7 @@ func TestTerminatePod(t *testing.T) {
t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses) t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses)
} }
if !reflect.DeepEqual(newStatus.ContainerStatuses[0].State, expectUnknownState) { if !reflect.DeepEqual(newStatus.ContainerStatuses[0].State, expectUnknownState) {
t.Errorf("terminated container state not defaulted: %s", diff.ObjectReflectDiff(newStatus.ContainerStatuses[0].State, expectUnknownState)) t.Errorf("terminated container state not defaulted: %s", cmp.Diff(newStatus.ContainerStatuses[0].State, expectUnknownState))
} }
if !reflect.DeepEqual(newStatus.ContainerStatuses[1].State, firstStatus.ContainerStatuses[1].State) { if !reflect.DeepEqual(newStatus.ContainerStatuses[1].State, firstStatus.ContainerStatuses[1].State) {
t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses) t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses)
@@ -674,22 +673,22 @@ func TestTerminatePodWaiting(t *testing.T) {
expectUnknownState := v1.ContainerState{Terminated: &v1.ContainerStateTerminated{Reason: "ContainerStatusUnknown", Message: "The container could not be located when the pod was terminated", ExitCode: 137}} expectUnknownState := v1.ContainerState{Terminated: &v1.ContainerStateTerminated{Reason: "ContainerStatusUnknown", Message: "The container could not be located when the pod was terminated", ExitCode: 137}}
if !reflect.DeepEqual(newStatus.InitContainerStatuses[0].State, expectUnknownState) { if !reflect.DeepEqual(newStatus.InitContainerStatuses[0].State, expectUnknownState) {
t.Errorf("terminated container state not defaulted: %s", diff.ObjectReflectDiff(newStatus.InitContainerStatuses[0].State, expectUnknownState)) t.Errorf("terminated container state not defaulted: %s", cmp.Diff(newStatus.InitContainerStatuses[0].State, expectUnknownState))
} }
if !reflect.DeepEqual(newStatus.InitContainerStatuses[1].State, firstStatus.InitContainerStatuses[1].State) { if !reflect.DeepEqual(newStatus.InitContainerStatuses[1].State, firstStatus.InitContainerStatuses[1].State) {
t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses) t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses)
} }
if !reflect.DeepEqual(newStatus.InitContainerStatuses[2].State, firstStatus.InitContainerStatuses[2].State) { if !reflect.DeepEqual(newStatus.InitContainerStatuses[2].State, firstStatus.InitContainerStatuses[2].State) {
t.Errorf("waiting container state not defaulted: %s", diff.ObjectReflectDiff(newStatus.InitContainerStatuses[2].State, firstStatus.InitContainerStatuses[2].State)) t.Errorf("waiting container state not defaulted: %s", cmp.Diff(newStatus.InitContainerStatuses[2].State, firstStatus.InitContainerStatuses[2].State))
} }
if !reflect.DeepEqual(newStatus.ContainerStatuses[0].State, expectUnknownState) { if !reflect.DeepEqual(newStatus.ContainerStatuses[0].State, expectUnknownState) {
t.Errorf("terminated container state not defaulted: %s", diff.ObjectReflectDiff(newStatus.ContainerStatuses[0].State, expectUnknownState)) t.Errorf("terminated container state not defaulted: %s", cmp.Diff(newStatus.ContainerStatuses[0].State, expectUnknownState))
} }
if !reflect.DeepEqual(newStatus.ContainerStatuses[1].State, firstStatus.ContainerStatuses[1].State) { if !reflect.DeepEqual(newStatus.ContainerStatuses[1].State, firstStatus.ContainerStatuses[1].State) {
t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses) t.Errorf("existing terminated container state not preserved: %#v", newStatus.ContainerStatuses)
} }
if !reflect.DeepEqual(newStatus.ContainerStatuses[2].State, expectUnknownState) { if !reflect.DeepEqual(newStatus.ContainerStatuses[2].State, expectUnknownState) {
t.Errorf("waiting container state not defaulted: %s", diff.ObjectReflectDiff(newStatus.ContainerStatuses[2].State, expectUnknownState)) t.Errorf("waiting container state not defaulted: %s", cmp.Diff(newStatus.ContainerStatuses[2].State, expectUnknownState))
} }
t.Logf("we expect the previous status update to be preserved.") t.Logf("we expect the previous status update to be preserved.")

View File

@@ -24,10 +24,10 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
"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/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/util/certificate/csr" "k8s.io/client-go/util/certificate/csr"
"k8s.io/kubernetes/pkg/apis/admissionregistration" "k8s.io/kubernetes/pkg/apis/admissionregistration"
@@ -293,7 +293,7 @@ func TestPrintEvent(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -394,7 +394,7 @@ func TestPrintNamespace(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -442,7 +442,7 @@ func TestPrintSecret(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -490,7 +490,7 @@ func TestPrintServiceAccount(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -590,7 +590,7 @@ func TestPrintNodeStatus(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -639,7 +639,7 @@ func TestPrintNodeRole(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -691,7 +691,7 @@ func TestPrintNodeOSImage(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -743,7 +743,7 @@ func TestPrintNodeKernelVersion(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -795,7 +795,7 @@ func TestPrintNodeContainerRuntimeVersion(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -832,7 +832,7 @@ func TestPrintNodeName(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -893,7 +893,7 @@ func TestPrintNodeExternalIP(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -955,7 +955,7 @@ func TestPrintNodeInternalIP(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -998,7 +998,7 @@ func TestPrintIngress(t *testing.T) {
} }
rows[0].Object.Object = nil rows[0].Object.Object = nil
if !reflect.DeepEqual(expected, rows) { if !reflect.DeepEqual(expected, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expected, rows)) t.Errorf("mismatch: %s", cmp.Diff(expected, rows))
} }
} }
@@ -1061,7 +1061,7 @@ func TestPrintIngressClass(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(testCase.expected, rows) { if !reflect.DeepEqual(testCase.expected, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(testCase.expected, rows)) t.Errorf("mismatch: %s", cmp.Diff(testCase.expected, rows))
} }
}) })
} }
@@ -1171,7 +1171,7 @@ func TestPrintServiceLoadBalancer(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -1531,7 +1531,7 @@ func TestPrintPod(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expect, rows) { if !reflect.DeepEqual(test.expect, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expect, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expect, rows))
} }
} }
} }
@@ -1655,7 +1655,7 @@ func TestPrintPodwide(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expect, rows) { if !reflect.DeepEqual(test.expect, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expect, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expect, rows))
} }
} }
} }
@@ -1737,7 +1737,7 @@ func TestPrintPodConditions(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expect, rows) { if !reflect.DeepEqual(test.expect, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expect, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expect, rows))
} }
} }
} }
@@ -1788,7 +1788,7 @@ func TestPrintPodList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expect, rows) { if !reflect.DeepEqual(test.expect, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(test.expect, rows)) t.Errorf("mismatch: %s", cmp.Diff(test.expect, rows))
} }
} }
} }
@@ -1899,7 +1899,7 @@ func TestPrintNonTerminatedPod(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expect, rows) { if !reflect.DeepEqual(test.expect, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expect, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expect, rows))
} }
} }
} }
@@ -1981,7 +1981,7 @@ func TestPrintPodTemplate(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -2031,7 +2031,7 @@ func TestPrintPodTemplateList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(expectedRows, rows) { if !reflect.DeepEqual(expectedRows, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expectedRows, rows)) t.Errorf("mismatch: %s", cmp.Diff(expectedRows, rows))
} }
} }
@@ -2148,7 +2148,7 @@ func TestPrintDeployment(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -2216,7 +2216,7 @@ func TestPrintDaemonSet(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -2288,7 +2288,7 @@ func TestPrintDaemonSetList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(expectedRows, rows) { if !reflect.DeepEqual(expectedRows, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expectedRows, rows)) t.Errorf("mismatch: %s", cmp.Diff(expectedRows, rows))
} }
} }
@@ -2437,7 +2437,7 @@ func TestPrintJob(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -2518,7 +2518,7 @@ func TestPrintJobList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(expectedRows, rows) { if !reflect.DeepEqual(expectedRows, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expectedRows, rows)) t.Errorf("mismatch: %s", cmp.Diff(expectedRows, rows))
} }
} }
@@ -3290,7 +3290,7 @@ func TestPrintHPA(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -3490,7 +3490,7 @@ func TestPrintService(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -3541,7 +3541,7 @@ func TestPrintServiceList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(expectedRows, rows) { if !reflect.DeepEqual(expectedRows, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expectedRows, rows)) t.Errorf("mismatch: %s", cmp.Diff(expectedRows, rows))
} }
} }
@@ -3598,7 +3598,7 @@ func TestPrintPodDisruptionBudget(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -3652,7 +3652,7 @@ func TestPrintPodDisruptionBudgetList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(expectedRows, rows) { if !reflect.DeepEqual(expectedRows, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expectedRows, rows)) t.Errorf("mismatch: %s", cmp.Diff(expectedRows, rows))
} }
} }
@@ -3729,7 +3729,7 @@ func TestPrintControllerRevision(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -3796,7 +3796,7 @@ func TestPrintConfigMap(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -3843,7 +3843,7 @@ func TestPrintNetworkPolicy(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -3918,7 +3918,7 @@ func TestPrintRoleBinding(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -3993,7 +3993,7 @@ func TestPrintClusterRoleBinding(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -4135,7 +4135,7 @@ func TestPrintCertificateSigningRequest(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -4262,7 +4262,7 @@ func TestPrintReplicationController(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -4352,7 +4352,7 @@ func TestPrintReplicaSet(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -4420,7 +4420,7 @@ func TestPrintReplicaSetList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(expectedRows, rows) { if !reflect.DeepEqual(expectedRows, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expectedRows, rows)) t.Errorf("mismatch: %s", cmp.Diff(expectedRows, rows))
} }
} }
@@ -4507,7 +4507,7 @@ func TestPrintStatefulSet(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -4651,7 +4651,7 @@ func TestPrintPersistentVolume(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -4774,7 +4774,7 @@ func TestPrintPersistentVolumeClaim(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -4842,7 +4842,7 @@ func TestPrintComponentStatus(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -4980,7 +4980,7 @@ func TestPrintCronJob(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5046,7 +5046,7 @@ func TestPrintCronJobList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(expectedRows, rows) { if !reflect.DeepEqual(expectedRows, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expectedRows, rows)) t.Errorf("mismatch: %s", cmp.Diff(expectedRows, rows))
} }
} }
@@ -5144,7 +5144,7 @@ func TestPrintStorageClass(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5191,7 +5191,7 @@ func TestPrintLease(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5233,7 +5233,7 @@ func TestPrintPriorityClass(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5274,7 +5274,7 @@ func TestPrintRuntimeClass(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5394,7 +5394,7 @@ func TestPrintEndpoint(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
@@ -5493,7 +5493,7 @@ func TestPrintEndpointSlice(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5641,7 +5641,7 @@ func TestPrintFlowSchema(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5718,7 +5718,7 @@ func TestPrintPriorityLevelConfiguration(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5840,7 +5840,7 @@ func TestPrintStorageVersion(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -5877,7 +5877,7 @@ func TestPrintScale(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -6399,7 +6399,7 @@ func TestPrintClusterCIDR(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("%d mismatch: %s", i, cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -6478,7 +6478,7 @@ func TestPrintClusterCIDRList(t *testing.T) {
rows[i].Object.Object = nil rows[i].Object.Object = nil
} }
if !reflect.DeepEqual(test.expected, rows) { if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(test.expected, rows)) t.Errorf("mismatch: %s", cmp.Diff(test.expected, rows))
} }
} }
} }
@@ -6507,7 +6507,7 @@ func TestPrintIPAddress(t *testing.T) {
} }
rows[0].Object.Object = nil rows[0].Object.Object = nil
if !reflect.DeepEqual(expected, rows) { if !reflect.DeepEqual(expected, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expected, rows)) t.Errorf("mismatch: %s", cmp.Diff(expected, rows))
} }
} }
@@ -6558,7 +6558,7 @@ func TestPrintIPAddressList(t *testing.T) {
} }
if !reflect.DeepEqual(expected, rows) { if !reflect.DeepEqual(expected, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(expected, rows)) t.Errorf("mismatch: %s", cmp.Diff(expected, rows))
} }
} }

View File

@@ -22,11 +22,11 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"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"
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"
@@ -167,11 +167,11 @@ func TestDropFields(t *testing.T) {
old := tc.oldNode.DeepCopy() old := tc.oldNode.DeepCopy()
// old node should never be changed // old node should never be changed
if !reflect.DeepEqual(tc.oldNode, old) { if !reflect.DeepEqual(tc.oldNode, old) {
t.Errorf("%v: old node changed: %v", tc.name, diff.ObjectReflectDiff(tc.oldNode, old)) t.Errorf("%v: old node changed: %v", tc.name, cmp.Diff(tc.oldNode, old))
} }
if !reflect.DeepEqual(tc.node, tc.compareNode) { if !reflect.DeepEqual(tc.node, tc.compareNode) {
t.Errorf("%v: unexpected node spec: %v", tc.name, diff.ObjectReflectDiff(tc.node, tc.compareNode)) t.Errorf("%v: unexpected node spec: %v", tc.name, cmp.Diff(tc.node, tc.compareNode))
} }
}() }()
} }

View File

@@ -21,7 +21,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"k8s.io/apimachinery/pkg/util/diff" "github.com/google/go-cmp/cmp"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request" genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
featuregatetesting "k8s.io/component-base/featuregate/testing" featuregatetesting "k8s.io/component-base/featuregate/testing"
@@ -86,19 +86,19 @@ func TestDropConditions(t *testing.T) {
// old pvc should never be changed // old pvc should never be changed
if !reflect.DeepEqual(oldPvc, oldPvcInfo.pvc()) { if !reflect.DeepEqual(oldPvc, oldPvcInfo.pvc()) {
t.Errorf("old pvc changed: %v", diff.ObjectReflectDiff(oldPvc, oldPvcInfo.pvc())) t.Errorf("old pvc changed: %v", cmp.Diff(oldPvc, oldPvcInfo.pvc()))
} }
switch { switch {
case oldPvcHasConditins || newPvcHasConditions: case oldPvcHasConditins || newPvcHasConditions:
// new pvc should not be changed if the feature is enabled, or if the old pvc had Conditions // new pvc should not be changed if the feature is enabled, or if the old pvc had Conditions
if !reflect.DeepEqual(newPvc, newPvcInfo.pvc()) { if !reflect.DeepEqual(newPvc, newPvcInfo.pvc()) {
t.Errorf("new pvc changed: %v", diff.ObjectReflectDiff(newPvc, newPvcInfo.pvc())) t.Errorf("new pvc changed: %v", cmp.Diff(newPvc, newPvcInfo.pvc()))
} }
default: default:
// new pvc should not need to be changed // new pvc should not need to be changed
if !reflect.DeepEqual(newPvc, newPvcInfo.pvc()) { if !reflect.DeepEqual(newPvc, newPvcInfo.pvc()) {
t.Errorf("new pvc changed: %v", diff.ObjectReflectDiff(newPvc, newPvcInfo.pvc())) t.Errorf("new pvc changed: %v", cmp.Diff(newPvc, newPvcInfo.pvc()))
} }
} }
}) })

View File

@@ -34,7 +34,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"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"
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
@@ -610,7 +609,7 @@ func TestConvertToTableList(t *testing.T) {
continue continue
} }
if !apiequality.Semantic.DeepEqual(test.out, out) { if !apiequality.Semantic.DeepEqual(test.out, out) {
t.Errorf("%d: mismatch: %s", i, diff.ObjectReflectDiff(test.out, out)) t.Errorf("%d: mismatch: %s", i, cmp.Diff(test.out, out))
} }
} }
} }

View File

@@ -20,9 +20,9 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/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/rest" "k8s.io/apiserver/pkg/registry/rest"
@@ -218,11 +218,11 @@ func TestDropDisabledField(t *testing.T) {
// old node should never be changed // old node should never be changed
if !reflect.DeepEqual(tc.oldSvc, old) { if !reflect.DeepEqual(tc.oldSvc, old) {
t.Errorf("%v: old svc changed: %v", tc.name, diff.ObjectReflectDiff(tc.oldSvc, old)) t.Errorf("%v: old svc changed: %v", tc.name, cmp.Diff(tc.oldSvc, old))
} }
if !reflect.DeepEqual(tc.svc, tc.compareSvc) { if !reflect.DeepEqual(tc.svc, tc.compareSvc) {
t.Errorf("%v: unexpected svc spec: %v", tc.name, diff.ObjectReflectDiff(tc.svc, tc.compareSvc)) t.Errorf("%v: unexpected svc spec: %v", tc.name, cmp.Diff(tc.svc, tc.compareSvc))
} }
}() }()
} }

View File

@@ -22,12 +22,12 @@ import (
"io" "io"
"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"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
apiserveradmission "k8s.io/apiserver/pkg/admission/initializer" apiserveradmission "k8s.io/apiserver/pkg/admission/initializer"
@@ -375,7 +375,7 @@ func (p *Plugin) admitPVCStatus(nodeName string, a admission.Attributes) error {
// ensure no metadata changed. nodes should not be able to relabel, add finalizers/owners, etc // ensure no metadata changed. nodes should not be able to relabel, add finalizers/owners, etc
if !apiequality.Semantic.DeepEqual(oldPVC, newPVC) { if !apiequality.Semantic.DeepEqual(oldPVC, newPVC) {
return admission.NewForbidden(a, fmt.Errorf("node %q is not allowed to update fields other than status.capacity and status.conditions: %v", nodeName, diff.ObjectReflectDiff(oldPVC, newPVC))) return admission.NewForbidden(a, fmt.Errorf("node %q is not allowed to update fields other than status.capacity and status.conditions: %v", nodeName, cmp.Diff(oldPVC, newPVC)))
} }
return nil return nil

View File

@@ -27,7 +27,6 @@ import (
corev1 "k8s.io/api/core/v1" corev1 "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/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
admissiontesting "k8s.io/apiserver/pkg/admission/testing" admissiontesting "k8s.io/apiserver/pkg/admission/testing"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"
@@ -224,10 +223,10 @@ func TestAssignsDefaultServiceAccountAndBoundTokenWithNoSecretTokens(t *testing.
} }
if !reflect.DeepEqual(expectedVolumes, pod.Spec.Volumes) { if !reflect.DeepEqual(expectedVolumes, pod.Spec.Volumes) {
t.Errorf("unexpected volumes: %s", diff.ObjectReflectDiff(expectedVolumes, pod.Spec.Volumes)) t.Errorf("unexpected volumes: %s", cmp.Diff(expectedVolumes, pod.Spec.Volumes))
} }
if !reflect.DeepEqual(expectedVolumeMounts, pod.Spec.Containers[0].VolumeMounts) { if !reflect.DeepEqual(expectedVolumeMounts, pod.Spec.Containers[0].VolumeMounts) {
t.Errorf("unexpected volumes: %s", diff.ObjectReflectDiff(expectedVolumeMounts, pod.Spec.Containers[0].VolumeMounts)) t.Errorf("unexpected volumes: %s", cmp.Diff(expectedVolumeMounts, pod.Spec.Containers[0].VolumeMounts))
} }
// ensure result converted to v1 matches defaulted object // ensure result converted to v1 matches defaulted object

View File

@@ -21,6 +21,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
"k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/equality"
@@ -30,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/runtime/serializer/json" "k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/util/diff"
utiljson "k8s.io/apimachinery/pkg/util/json" utiljson "k8s.io/apimachinery/pkg/util/json"
clientgoscheme "k8s.io/client-go/kubernetes/scheme" clientgoscheme "k8s.io/client-go/kubernetes/scheme"
) )
@@ -56,7 +56,7 @@ func TestRoundtripObjectMeta(t *testing.T) {
} }
if !equality.Semantic.DeepEqual(original, o) { if !equality.Semantic.DeepEqual(original, o) {
t.Errorf("diff: %v\nCodec: %#v", diff.ObjectReflectDiff(original, o), codec) t.Errorf("diff: %v\nCodec: %#v", cmp.Diff(original, o), codec)
} }
} }
} }
@@ -153,7 +153,7 @@ func TestMalformedObjectMetaFields(t *testing.T) {
} }
if !equality.Semantic.DeepEqual(expectedObjectMeta, actualObjectMeta) { if !equality.Semantic.DeepEqual(expectedObjectMeta, actualObjectMeta) {
t.Errorf("%v=%#v, diff: %v\n", pth, v, diff.ObjectReflectDiff(expectedObjectMeta, actualObjectMeta)) t.Errorf("%v=%#v, diff: %v\n", pth, v, cmp.Diff(expectedObjectMeta, actualObjectMeta))
t.Errorf("expectedObjectMeta %#v", expectedObjectMeta) t.Errorf("expectedObjectMeta %#v", expectedObjectMeta)
} }
} }

View File

@@ -23,11 +23,11 @@ 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/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/util/jsonpath" "k8s.io/client-go/util/jsonpath"
) )
@@ -434,7 +434,7 @@ func Test_convertor_ConvertToTable(t *testing.T) {
return return
} }
if !reflect.DeepEqual(got, tt.want) { if !reflect.DeepEqual(got, tt.want) {
t.Errorf("convertor.ConvertToTable() = %s", diff.ObjectReflectDiff(tt.want, got)) t.Errorf("convertor.ConvertToTable() = %s", cmp.Diff(tt.want, got))
} }
}) })
} }

View File

@@ -26,6 +26,7 @@ import (
//nolint:staticcheck //iccheck // SA1019 Keep using deprecated module; it still seems to be maintained and the api of the recommended replacement differs //nolint:staticcheck //iccheck // SA1019 Keep using deprecated module; it still seems to be maintained and the api of the recommended replacement differs
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"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"
@@ -39,7 +40,6 @@ import (
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/runtime/serializer/json" "k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/runtime/serializer/protobuf" "k8s.io/apimachinery/pkg/runtime/serializer/protobuf"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/dump" "k8s.io/apimachinery/pkg/util/dump"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
) )
@@ -305,7 +305,7 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
object = object.DeepCopyObject() object = object.DeepCopyObject()
name := reflect.TypeOf(object).Elem().Name() name := reflect.TypeOf(object).Elem().Name()
if !apiequality.Semantic.DeepEqual(original, object) { if !apiequality.Semantic.DeepEqual(original, object) {
t.Errorf("%v: DeepCopy altered the object, diff: %v", name, diff.ObjectReflectDiff(original, object)) t.Errorf("%v: DeepCopy altered the object, diff: %v", name, cmp.Diff(original, object))
t.Errorf("%s", dump.Pretty(original)) t.Errorf("%s", dump.Pretty(original))
t.Errorf("%s", dump.Pretty(object)) t.Errorf("%s", dump.Pretty(object))
return return
@@ -326,7 +326,7 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
// copy or conversion should alter the object // copy or conversion should alter the object
// TODO eliminate this global // TODO eliminate this global
if !apiequality.Semantic.DeepEqual(original, object) { if !apiequality.Semantic.DeepEqual(original, object) {
t.Errorf("%v: encode altered the object, diff: %v", name, diff.ObjectReflectDiff(original, object)) t.Errorf("%v: encode altered the object, diff: %v", name, cmp.Diff(original, object))
return return
} }
@@ -357,7 +357,7 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
// ensure that the object produced from decoding the encoded data is equal // ensure that the object produced from decoding the encoded data is equal
// to the original object // to the original object
if !apiequality.Semantic.DeepEqual(original, obj2) { if !apiequality.Semantic.DeepEqual(original, obj2) {
t.Errorf("%v: diff: %v\nCodec: %#v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, diff.ObjectReflectDiff(original, obj2), codec, dump.Pretty(original), dataAsString(data), dump.Pretty(obj2)) t.Errorf("%v: diff: %v\nCodec: %#v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, cmp.Diff(original, obj2), codec, dump.Pretty(original), dataAsString(data), dump.Pretty(obj2))
return return
} }
@@ -395,7 +395,7 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
// ensure that the new runtime object is equal to the original after being // ensure that the new runtime object is equal to the original after being
// decoded into // decoded into
if !apiequality.Semantic.DeepEqual(object, obj3) { if !apiequality.Semantic.DeepEqual(object, obj3) {
t.Errorf("%v: diff: %v\nCodec: %#v", name, diff.ObjectReflectDiff(object, obj3), codec) t.Errorf("%v: diff: %v\nCodec: %#v", name, cmp.Diff(object, obj3), codec)
return return
} }
@@ -404,7 +404,7 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
// NOTE: we use the encoding+decoding here as an alternative, guaranteed deep-copy to compare against. // NOTE: we use the encoding+decoding here as an alternative, guaranteed deep-copy to compare against.
fuzzer.ValueFuzz(object) fuzzer.ValueFuzz(object)
if !apiequality.Semantic.DeepEqual(original, obj3) { if !apiequality.Semantic.DeepEqual(original, obj3) {
t.Errorf("%v: fuzzing a copy altered the original, diff: %v", name, diff.ObjectReflectDiff(original, obj3)) t.Errorf("%v: fuzzing a copy altered the original, diff: %v", name, cmp.Diff(original, obj3))
return return
} }
} }

View File

@@ -23,8 +23,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/util/diff"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
) )
@@ -36,7 +36,7 @@ func TestAsPartialObjectMetadata(t *testing.T) {
f.Fuzz(m) f.Fuzz(m)
partial := AsPartialObjectMetadata(m) partial := AsPartialObjectMetadata(m)
if !reflect.DeepEqual(&partial.ObjectMeta, m) { if !reflect.DeepEqual(&partial.ObjectMeta, m) {
t.Fatalf("incomplete partial object metadata: %s", diff.ObjectReflectDiff(&partial.ObjectMeta, m)) t.Fatalf("incomplete partial object metadata: %s", cmp.Diff(&partial.ObjectMeta, m))
} }
} }
@@ -45,7 +45,7 @@ func TestAsPartialObjectMetadata(t *testing.T) {
f.Fuzz(&m.ObjectMeta) f.Fuzz(&m.ObjectMeta)
partial := AsPartialObjectMetadata(m) partial := AsPartialObjectMetadata(m)
if !reflect.DeepEqual(&partial.ObjectMeta, &m.ObjectMeta) { if !reflect.DeepEqual(&partial.ObjectMeta, &m.ObjectMeta) {
t.Fatalf("incomplete partial object metadata: %s", diff.ObjectReflectDiff(&partial.ObjectMeta, &m.ObjectMeta)) t.Fatalf("incomplete partial object metadata: %s", cmp.Diff(&partial.ObjectMeta, &m.ObjectMeta))
} }
} }
} }

View File

@@ -21,9 +21,9 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
) )
func TestListOptions(t *testing.T) { func TestListOptions(t *testing.T) {
@@ -45,7 +45,7 @@ func TestListOptions(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(in, actual) { if !reflect.DeepEqual(in, actual) {
t.Errorf("unexpected: %s", diff.ObjectReflectDiff(in, actual)) t.Errorf("unexpected: %s", cmp.Diff(in, actual))
} }
// verify failing conversion // verify failing conversion
@@ -85,6 +85,6 @@ func TestListOptions(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(in, actual) { if !reflect.DeepEqual(in, actual) {
t.Errorf("unexpected: %s", diff.ObjectReflectDiff(in, actual)) t.Errorf("unexpected: %s", cmp.Diff(in, actual))
} }
} }

View File

@@ -21,6 +21,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
"k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/equality"
@@ -29,7 +30,6 @@ import (
"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/serializer" "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/diff"
) )
func TestNilUnstructuredContent(t *testing.T) { func TestNilUnstructuredContent(t *testing.T) {
@@ -65,7 +65,7 @@ func TestUnstructuredMetadataRoundTrip(t *testing.T) {
setObjectMetaUsingAccessors(u, uCopy) setObjectMetaUsingAccessors(u, uCopy)
if !equality.Semantic.DeepEqual(u, uCopy) { if !equality.Semantic.DeepEqual(u, uCopy) {
t.Errorf("diff: %v", diff.ObjectReflectDiff(u, uCopy)) t.Errorf("diff: %v", cmp.Diff(u, uCopy))
} }
} }
} }

View File

@@ -33,9 +33,9 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/conversion" "k8s.io/apimachinery/pkg/conversion"
"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"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -194,7 +194,7 @@ func doRoundTrip(t *testing.T, item interface{}) {
return return
} }
if !reflect.DeepEqual(item, unmarshalledObj) { if !reflect.DeepEqual(item, unmarshalledObj) {
t.Errorf("Object changed during JSON operations, diff: %v", diff.ObjectReflectDiff(item, unmarshalledObj)) t.Errorf("Object changed during JSON operations, diff: %v", cmp.Diff(item, unmarshalledObj))
return return
} }
@@ -213,7 +213,7 @@ func doRoundTrip(t *testing.T, item interface{}) {
} }
if !reflect.DeepEqual(item, newObj) { if !reflect.DeepEqual(item, newObj) {
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(item, newObj)) t.Errorf("Object changed, diff: %v", cmp.Diff(item, newObj))
} }
} }
@@ -687,7 +687,7 @@ func doUnrecognized(t *testing.T, jsonData string, item interface{}, expectedErr
} }
if expectedErr == nil && !reflect.DeepEqual(unmarshalledObj, newObj) { if expectedErr == nil && !reflect.DeepEqual(unmarshalledObj, newObj) {
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(unmarshalledObj, newObj)) t.Errorf("Object changed, diff: %v", cmp.Diff(unmarshalledObj, newObj))
} }
} }
@@ -916,7 +916,7 @@ func TestFloatIntConversion(t *testing.T) {
} }
if !reflect.DeepEqual(obj, unmarshalled) { if !reflect.DeepEqual(obj, unmarshalled) {
t.Errorf("Incorrect conversion, diff: %v", diff.ObjectReflectDiff(obj, unmarshalled)) t.Errorf("Incorrect conversion, diff: %v", cmp.Diff(obj, unmarshalled))
} }
} }
@@ -938,7 +938,7 @@ func TestIntFloatConversion(t *testing.T) {
} }
if !reflect.DeepEqual(obj, unmarshalled) { if !reflect.DeepEqual(obj, unmarshalled) {
t.Errorf("Incorrect conversion, diff: %v", diff.ObjectReflectDiff(obj, unmarshalled)) t.Errorf("Incorrect conversion, diff: %v", cmp.Diff(obj, unmarshalled))
} }
} }

View File

@@ -20,8 +20,8 @@ import (
"reflect" "reflect"
"testing" "testing"
"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 TestResourceMapper(t *testing.T) { func TestResourceMapper(t *testing.T) {
@@ -122,14 +122,14 @@ func TestResourceMapper(t *testing.T) {
// Verify equivalents to primary resource // Verify equivalents to primary resource
if resources := mapper.EquivalentResourcesFor(gvr("apps", "v1", "deployments"), ""); !reflect.DeepEqual(resources, tc.ResourcesForV1Deployment) { if resources := mapper.EquivalentResourcesFor(gvr("apps", "v1", "deployments"), ""); !reflect.DeepEqual(resources, tc.ResourcesForV1Deployment) {
t.Errorf("diff:\n%s", diff.ObjectReflectDiff(tc.ResourcesForV1Deployment, resources)) t.Errorf("diff:\n%s", cmp.Diff(tc.ResourcesForV1Deployment, resources))
} }
// Verify equivalents to subresources // Verify equivalents to subresources
if resources := mapper.EquivalentResourcesFor(gvr("apps", "v1", "deployments"), "scale"); !reflect.DeepEqual(resources, tc.ResourcesForV1DeploymentScale) { if resources := mapper.EquivalentResourcesFor(gvr("apps", "v1", "deployments"), "scale"); !reflect.DeepEqual(resources, tc.ResourcesForV1DeploymentScale) {
t.Errorf("diff:\n%s", diff.ObjectReflectDiff(tc.ResourcesForV1DeploymentScale, resources)) t.Errorf("diff:\n%s", cmp.Diff(tc.ResourcesForV1DeploymentScale, resources))
} }
if resources := mapper.EquivalentResourcesFor(gvr("apps", "v1", "deployments"), "status"); !reflect.DeepEqual(resources, tc.ResourcesForV1DeploymentStatus) { if resources := mapper.EquivalentResourcesFor(gvr("apps", "v1", "deployments"), "status"); !reflect.DeepEqual(resources, tc.ResourcesForV1DeploymentStatus) {
t.Errorf("diff:\n%s", diff.ObjectReflectDiff(tc.ResourcesForV1DeploymentStatus, resources)) t.Errorf("diff:\n%s", cmp.Diff(tc.ResourcesForV1DeploymentStatus, resources))
} }
}) })
} }

View File

@@ -22,6 +22,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/conversion" "k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
@@ -856,17 +857,17 @@ func TestConvertToVersion(t *testing.T) {
if test.same { if test.same {
if !reflect.DeepEqual(original, test.in) { if !reflect.DeepEqual(original, test.in) {
t.Fatalf("unexpected mutation of input: %s", diff.ObjectReflectDiff(original, test.in)) t.Fatalf("unexpected mutation of input: %s", cmp.Diff(original, test.in))
} }
if !reflect.DeepEqual(out, test.out) { if !reflect.DeepEqual(out, test.out) {
t.Fatalf("unexpected out: %s", diff.ObjectReflectDiff(out, test.out)) t.Fatalf("unexpected out: %s", cmp.Diff(out, test.out))
} }
unsafe, err := test.scheme.UnsafeConvertToVersion(test.in, test.gv) unsafe, err := test.scheme.UnsafeConvertToVersion(test.in, test.gv)
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
if !reflect.DeepEqual(unsafe, test.out) { if !reflect.DeepEqual(unsafe, test.out) {
t.Fatalf("unexpected unsafe: %s", diff.ObjectReflectDiff(unsafe, test.out)) t.Fatalf("unexpected unsafe: %s", cmp.Diff(unsafe, test.out))
} }
if unsafe != test.in { if unsafe != test.in {
t.Fatalf("UnsafeConvertToVersion should return same object: %#v", unsafe) t.Fatalf("UnsafeConvertToVersion should return same object: %#v", unsafe)
@@ -874,7 +875,7 @@ func TestConvertToVersion(t *testing.T) {
return return
} }
if !reflect.DeepEqual(out, test.out) { if !reflect.DeepEqual(out, test.out) {
t.Fatalf("unexpected out: %s", diff.ObjectReflectDiff(out, test.out)) t.Fatalf("unexpected out: %s", cmp.Diff(out, test.out))
} }
}) })
} }
@@ -917,7 +918,7 @@ func TestConvert(t *testing.T) {
} }
if !reflect.DeepEqual(test.into, test.out) { if !reflect.DeepEqual(test.into, test.out) {
t.Fatalf("unexpected out: %s", diff.ObjectReflectDiff(test.into, test.out)) t.Fatalf("unexpected out: %s", cmp.Diff(test.into, test.out))
} }
}) })
} }

View File

@@ -29,7 +29,7 @@ import (
"regexp" "regexp"
"testing" "testing"
"k8s.io/apimachinery/pkg/util/diff" "github.com/google/go-cmp/cmp"
utilnet "k8s.io/apimachinery/pkg/util/net" utilnet "k8s.io/apimachinery/pkg/util/net"
) )
@@ -147,7 +147,7 @@ func TestDialURL(t *testing.T) {
// Make sure dialing doesn't mutate the transport's TLSConfig // Make sure dialing doesn't mutate the transport's TLSConfig
if !reflect.DeepEqual(tc.TLSConfig, tlsConfigCopy) { if !reflect.DeepEqual(tc.TLSConfig, tlsConfigCopy) {
t.Errorf("%s: transport's copy of TLSConfig was mutated\n%s", k, diff.ObjectReflectDiff(tc.TLSConfig, tlsConfigCopy)) t.Errorf("%s: transport's copy of TLSConfig was mutated\n%s", k, cmp.Diff(tc.TLSConfig, tlsConfigCopy))
} }
if err != nil { if err != nil {

View File

@@ -21,13 +21,13 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
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/apiserver/pkg/apis/example" "k8s.io/apiserver/pkg/apis/example"
examplev1 "k8s.io/apiserver/pkg/apis/example/v1" examplev1 "k8s.io/apiserver/pkg/apis/example/v1"
example2v1 "k8s.io/apiserver/pkg/apis/example2/v1" example2v1 "k8s.io/apiserver/pkg/apis/example2/v1"
@@ -341,22 +341,22 @@ func TestConvertVersionedAttributes(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if e, a := tc.ExpectedAttrs.Attributes.GetObject(), tc.Attrs.Attributes.GetObject(); !reflect.DeepEqual(e, a) { if e, a := tc.ExpectedAttrs.Attributes.GetObject(), tc.Attrs.Attributes.GetObject(); !reflect.DeepEqual(e, a) {
t.Errorf("unexpected diff:\n%s", diff.ObjectReflectDiff(e, a)) t.Errorf("unexpected diff:\n%s", cmp.Diff(e, a))
} }
if e, a := tc.ExpectedAttrs.Attributes.GetOldObject(), tc.Attrs.Attributes.GetOldObject(); !reflect.DeepEqual(e, a) { if e, a := tc.ExpectedAttrs.Attributes.GetOldObject(), tc.Attrs.Attributes.GetOldObject(); !reflect.DeepEqual(e, a) {
t.Errorf("unexpected diff:\n%s", diff.ObjectReflectDiff(e, a)) t.Errorf("unexpected diff:\n%s", cmp.Diff(e, a))
} }
if e, a := tc.ExpectedAttrs.VersionedKind, tc.Attrs.VersionedKind; !reflect.DeepEqual(e, a) { if e, a := tc.ExpectedAttrs.VersionedKind, tc.Attrs.VersionedKind; !reflect.DeepEqual(e, a) {
t.Errorf("unexpected diff:\n%s", diff.ObjectReflectDiff(e, a)) t.Errorf("unexpected diff:\n%s", cmp.Diff(e, a))
} }
if e, a := tc.ExpectedAttrs.VersionedObject, tc.Attrs.VersionedObject; !reflect.DeepEqual(e, a) { if e, a := tc.ExpectedAttrs.VersionedObject, tc.Attrs.VersionedObject; !reflect.DeepEqual(e, a) {
t.Errorf("unexpected diff:\n%s", diff.ObjectReflectDiff(e, a)) t.Errorf("unexpected diff:\n%s", cmp.Diff(e, a))
} }
if e, a := tc.ExpectedAttrs.VersionedOldObject, tc.Attrs.VersionedOldObject; !reflect.DeepEqual(e, a) { if e, a := tc.ExpectedAttrs.VersionedOldObject, tc.Attrs.VersionedOldObject; !reflect.DeepEqual(e, a) {
t.Errorf("unexpected diff:\n%s", diff.ObjectReflectDiff(e, a)) t.Errorf("unexpected diff:\n%s", cmp.Diff(e, a))
} }
if e, a := tc.ExpectedAttrs.Dirty, tc.Attrs.Dirty; !reflect.DeepEqual(e, a) { if e, a := tc.ExpectedAttrs.Dirty, tc.Attrs.Dirty; !reflect.DeepEqual(e, a) {
t.Errorf("unexpected diff:\n%s", diff.ObjectReflectDiff(e, a)) t.Errorf("unexpected diff:\n%s", cmp.Diff(e, a))
} }
}) })
} }

View File

@@ -23,12 +23,12 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"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/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
@@ -202,7 +202,7 @@ func TestAdmissionNamespaceTerminating(t *testing.T) {
Field: "metadata.namespace", Field: "metadata.namespace",
} }
if cause, ok := errors.StatusCause(err, v1.NamespaceTerminatingCause); !ok || !reflect.DeepEqual(expectedCause, cause) { if cause, ok := errors.StatusCause(err, v1.NamespaceTerminatingCause); !ok || !reflect.DeepEqual(expectedCause, cause) {
t.Errorf("Expected status cause indicating the namespace is terminating: %t %s", ok, diff.ObjectReflectDiff(expectedCause, cause)) t.Errorf("Expected status cause indicating the namespace is terminating: %t %s", ok, cmp.Diff(expectedCause, cause))
} }
// verify update operations in the namespace can proceed // verify update operations in the namespace can proceed

View File

@@ -21,9 +21,9 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
"k8s.io/api/admissionregistration/v1" v1 "k8s.io/api/admissionregistration/v1"
"k8s.io/apimachinery/pkg/util/diff"
) )
func TestMutatingWebhookAccessor(t *testing.T) { func TestMutatingWebhookAccessor(t *testing.T) {
@@ -46,7 +46,7 @@ func TestMutatingWebhookAccessor(t *testing.T) {
t.Errorf("expected GetMutatingWebhook to return ok for mutating webhook accessor") t.Errorf("expected GetMutatingWebhook to return ok for mutating webhook accessor")
} }
if !reflect.DeepEqual(orig, m) { if !reflect.DeepEqual(orig, m) {
t.Errorf("expected GetMutatingWebhook to return original webhook, diff:\n%s", diff.ObjectReflectDiff(orig, m)) t.Errorf("expected GetMutatingWebhook to return original webhook, diff:\n%s", cmp.Diff(orig, m))
} }
if _, ok := accessor.GetValidatingWebhook(); ok { if _, ok := accessor.GetValidatingWebhook(); ok {
t.Errorf("expected GetValidatingWebhook to be nil for mutating webhook accessor") t.Errorf("expected GetValidatingWebhook to be nil for mutating webhook accessor")
@@ -65,7 +65,7 @@ func TestMutatingWebhookAccessor(t *testing.T) {
MatchConditions: accessor.GetMatchConditions(), MatchConditions: accessor.GetMatchConditions(),
} }
if !reflect.DeepEqual(orig, copy) { if !reflect.DeepEqual(orig, copy) {
t.Errorf("expected mutatingWebhook to round trip through WebhookAccessor, diff:\n%s", diff.ObjectReflectDiff(orig, copy)) t.Errorf("expected mutatingWebhook to round trip through WebhookAccessor, diff:\n%s", cmp.Diff(orig, copy))
} }
}) })
} }
@@ -87,7 +87,7 @@ func TestValidatingWebhookAccessor(t *testing.T) {
t.Errorf("expected GetValidatingWebhook to return ok for validating webhook accessor") t.Errorf("expected GetValidatingWebhook to return ok for validating webhook accessor")
} }
if !reflect.DeepEqual(orig, m) { if !reflect.DeepEqual(orig, m) {
t.Errorf("expected GetValidatingWebhook to return original webhook, diff:\n%s", diff.ObjectReflectDiff(orig, m)) t.Errorf("expected GetValidatingWebhook to return original webhook, diff:\n%s", cmp.Diff(orig, m))
} }
if _, ok := accessor.GetMutatingWebhook(); ok { if _, ok := accessor.GetMutatingWebhook(); ok {
t.Errorf("expected GetMutatingWebhook to be nil for validating webhook accessor") t.Errorf("expected GetMutatingWebhook to be nil for validating webhook accessor")
@@ -106,7 +106,7 @@ func TestValidatingWebhookAccessor(t *testing.T) {
MatchConditions: accessor.GetMatchConditions(), MatchConditions: accessor.GetMatchConditions(),
} }
if !reflect.DeepEqual(orig, copy) { if !reflect.DeepEqual(orig, copy) {
t.Errorf("expected validatingWebhook to round trip through WebhookAccessor, diff:\n%s", diff.ObjectReflectDiff(orig, copy)) t.Errorf("expected validatingWebhook to round trip through WebhookAccessor, diff:\n%s", cmp.Diff(orig, copy))
} }
}) })
} }

View File

@@ -21,9 +21,9 @@ 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/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
) )
@@ -63,7 +63,7 @@ func (r *reinvoker) Admit(ctx context.Context, a admission.Attributes, o admissi
} }
for i := 1; i < len(outputs); i++ { for i := 1; i < len(outputs); i++ {
if !apiequality.Semantic.DeepEqual(outputs[0], outputs[i]) { if !apiequality.Semantic.DeepEqual(outputs[0], outputs[i]) {
r.t.Errorf("expected mutating admission plugin to be idempontent, but got different results on reinvocation, diff:\n%s", diff.ObjectReflectDiff(outputs[0], outputs[i])) r.t.Errorf("expected mutating admission plugin to be idempontent, but got different results on reinvocation, diff:\n%s", cmp.Diff(outputs[0], outputs[i]))
} }
} }
return nil return nil

View File

@@ -56,7 +56,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming" "k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/net"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
@@ -1833,7 +1832,7 @@ func TestGetTable(t *testing.T) {
} }
if !reflect.DeepEqual(test.expected, &itemOut) { if !reflect.DeepEqual(test.expected, &itemOut) {
t.Log(body) t.Log(body)
t.Errorf("%d: did not match: %s", i, diff.ObjectReflectDiff(test.expected, &itemOut)) t.Errorf("%d: did not match: %s", i, cmp.Diff(test.expected, &itemOut))
} }
}) })
} }
@@ -2062,7 +2061,7 @@ func TestWatchTable(t *testing.T) {
actual = append(actual, &event) actual = append(actual, &event)
} }
if !reflect.DeepEqual(test.expected, actual) { if !reflect.DeepEqual(test.expected, actual) {
t.Fatalf("unexpected: %s", diff.ObjectReflectDiff(test.expected, actual)) t.Fatalf("unexpected: %s", cmp.Diff(test.expected, actual))
} }
}) })
} }
@@ -2240,7 +2239,7 @@ func TestGetPartialObjectMetadata(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !reflect.DeepEqual(test.expected, itemOut) { if !reflect.DeepEqual(test.expected, itemOut) {
t.Errorf("%d: did not match: %s", i, diff.ObjectReflectDiff(test.expected, itemOut)) t.Errorf("%d: did not match: %s", i, cmp.Diff(test.expected, itemOut))
} }
body = d body = d
} else { } else {

View File

@@ -35,11 +35,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors" kerrors "k8s.io/apimachinery/pkg/api/errors"
"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/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apiserver/pkg/features" "k8s.io/apiserver/pkg/features"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
@@ -114,7 +114,7 @@ func TestSerializeObjectParallel(t *testing.T) {
t.Fatalf("unexpected code: %v", result.StatusCode) t.Fatalf("unexpected code: %v", result.StatusCode)
} }
if !reflect.DeepEqual(result.Header, ctt.wantHeaders) { if !reflect.DeepEqual(result.Header, ctt.wantHeaders) {
t.Fatal(diff.ObjectReflectDiff(ctt.wantHeaders, result.Header)) t.Fatal(cmp.Diff(ctt.wantHeaders, result.Header))
} }
}) })
} }
@@ -364,7 +364,7 @@ func TestSerializeObject(t *testing.T) {
t.Fatalf("unexpected code: %v", result.StatusCode) t.Fatalf("unexpected code: %v", result.StatusCode)
} }
if !reflect.DeepEqual(result.Header, tt.wantHeaders) { if !reflect.DeepEqual(result.Header, tt.wantHeaders) {
t.Fatal(diff.ObjectReflectDiff(tt.wantHeaders, result.Header)) t.Fatal(cmp.Diff(tt.wantHeaders, result.Header))
} }
body, _ := ioutil.ReadAll(result.Body) body, _ := ioutil.ReadAll(result.Body)
if !bytes.Equal(tt.wantBody, body) { if !bytes.Equal(tt.wantBody, body) {

View File

@@ -39,7 +39,6 @@ import (
"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/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/json"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/apimachinery/pkg/util/strategicpatch"
@@ -1280,7 +1279,7 @@ func TestDedupOwnerReferences(t *testing.T) {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
deduped, _ := dedupOwnerReferences(tc.ownerReferences) deduped, _ := dedupOwnerReferences(tc.ownerReferences)
if !apiequality.Semantic.DeepEqual(deduped, tc.expected) { if !apiequality.Semantic.DeepEqual(deduped, tc.expected) {
t.Errorf("diff: %v", diff.ObjectReflectDiff(deduped, tc.expected)) t.Errorf("diff: %v", cmp.Diff(deduped, tc.expected))
} }
}) })
} }

View File

@@ -24,13 +24,13 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1" 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/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/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"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"
"k8s.io/apiserver/pkg/storage" "k8s.io/apiserver/pkg/storage"
@@ -189,7 +189,7 @@ TestCase:
for j, event := range testCase.expected { for j, event := range testCase.expected {
e := <-ch e := <-ch
if !reflect.DeepEqual(event, e) { if !reflect.DeepEqual(event, e) {
t.Errorf("%d: unexpected event %d: %s", i, j, diff.ObjectReflectDiff(event, e)) t.Errorf("%d: unexpected event %d: %s", i, j, cmp.Diff(event, e))
break TestCase break TestCase
} }
} }

View File

@@ -19,8 +19,8 @@ package webhook
import ( import (
"testing" "testing"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api" clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
) )
@@ -230,7 +230,7 @@ func TestAuthenticationDetection(t *testing.T) {
actual.Timeout = 0 actual.Timeout = 0
if !equality.Semantic.DeepEqual(*actual, tc.expected) { if !equality.Semantic.DeepEqual(*actual, tc.expected) {
t.Errorf("%v", diff.ObjectReflectDiff(tc.expected, *actual)) t.Errorf("%v", cmp.Diff(tc.expected, *actual))
} }
}) })
} }

View File

@@ -23,11 +23,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
authenticationv1 "k8s.io/api/authentication/v1" authenticationv1 "k8s.io/api/authentication/v1"
authenticationv1beta1 "k8s.io/api/authentication/v1beta1" authenticationv1beta1 "k8s.io/api/authentication/v1beta1"
"k8s.io/apimachinery/pkg/util/diff"
) )
func TestRoundTrip(t *testing.T) { func TestRoundTrip(t *testing.T) {
@@ -49,7 +49,7 @@ func TestRoundTrip(t *testing.T) {
Status: v1beta1StatusToV1Status(&converted.Status), Status: v1beta1StatusToV1Status(&converted.Status),
} }
if !reflect.DeepEqual(original, roundtripped) { if !reflect.DeepEqual(original, roundtripped) {
t.Errorf("diff %s", diff.ObjectReflectDiff(original, roundtripped)) t.Errorf("diff %s", cmp.Diff(original, roundtripped))
} }
} }
} }

View File

@@ -23,11 +23,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
authorizationv1 "k8s.io/api/authorization/v1" authorizationv1 "k8s.io/api/authorization/v1"
authorizationv1beta1 "k8s.io/api/authorization/v1beta1" authorizationv1beta1 "k8s.io/api/authorization/v1beta1"
"k8s.io/apimachinery/pkg/util/diff"
) )
func TestRoundTrip(t *testing.T) { func TestRoundTrip(t *testing.T) {
@@ -49,7 +49,7 @@ func TestRoundTrip(t *testing.T) {
Status: v1beta1StatusToV1Status(&converted.Status), Status: v1beta1StatusToV1Status(&converted.Status),
} }
if !reflect.DeepEqual(original, roundtripped) { if !reflect.DeepEqual(original, roundtripped) {
t.Errorf("diff %s", diff.ObjectReflectDiff(original, roundtripped)) t.Errorf("diff %s", cmp.Diff(original, roundtripped))
} }
} }
} }

View File

@@ -36,7 +36,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"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/version" "k8s.io/apimachinery/pkg/version"
"k8s.io/client-go/openapi" "k8s.io/client-go/openapi"
@@ -437,7 +436,7 @@ func TestGetServerResourcesForGroupVersion(t *testing.T) {
"extensions/v1beta10", "extensions/v1beta10",
} }
if !reflect.DeepEqual(expectedGroupVersions, serverGroupVersions) { if !reflect.DeepEqual(expectedGroupVersions, serverGroupVersions) {
t.Errorf("unexpected group versions: %v", diff.ObjectReflectDiff(expectedGroupVersions, serverGroupVersions)) t.Errorf("unexpected group versions: %v", cmp.Diff(expectedGroupVersions, serverGroupVersions))
} }
} }

View File

@@ -26,11 +26,11 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1" corev1 "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/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
) )
@@ -89,7 +89,7 @@ func TestClient(t *testing.T) {
}, },
} }
if !reflect.DeepEqual(expect, obj) { if !reflect.DeepEqual(expect, obj) {
t.Fatal(diff.ObjectReflectDiff(expect, obj)) t.Fatal(cmp.Diff(expect, obj))
} }
}, },
}, },
@@ -146,7 +146,7 @@ func TestClient(t *testing.T) {
}, },
} }
if !reflect.DeepEqual(expect, objs.Items) { if !reflect.DeepEqual(expect, objs.Items) {
t.Fatal(diff.ObjectReflectDiff(expect, objs.Items)) t.Fatal(cmp.Diff(expect, objs.Items))
} }
}, },
}, },

View File

@@ -45,7 +45,6 @@ import (
"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/runtime/serializer/streaming" "k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
utilnet "k8s.io/apimachinery/pkg/util/net" utilnet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
@@ -925,22 +924,22 @@ func TestTransformUnstructuredError(t *testing.T) {
expect = err expect = err
} }
if !reflect.DeepEqual(expect, transformed) { if !reflect.DeepEqual(expect, transformed) {
t.Errorf("unexpected Error(): %s", diff.ObjectReflectDiff(expect, transformed)) t.Errorf("unexpected Error(): %s", cmp.Diff(expect, transformed))
} }
// verify result.Get properly transforms the error // verify result.Get properly transforms the error
if _, err := result.Get(); !reflect.DeepEqual(expect, err) { if _, err := result.Get(); !reflect.DeepEqual(expect, err) {
t.Errorf("unexpected error on Get(): %s", diff.ObjectReflectDiff(expect, err)) t.Errorf("unexpected error on Get(): %s", cmp.Diff(expect, err))
} }
// verify result.Into properly handles the error // verify result.Into properly handles the error
if err := result.Into(&v1.Pod{}); !reflect.DeepEqual(expect, err) { if err := result.Into(&v1.Pod{}); !reflect.DeepEqual(expect, err) {
t.Errorf("unexpected error on Into(): %s", diff.ObjectReflectDiff(expect, err)) t.Errorf("unexpected error on Into(): %s", cmp.Diff(expect, err))
} }
// verify result.Raw leaves the error in the untransformed state // verify result.Raw leaves the error in the untransformed state
if _, err := result.Raw(); !reflect.DeepEqual(result.err, err) { if _, err := result.Raw(); !reflect.DeepEqual(result.err, err) {
t.Errorf("unexpected error on Raw(): %s", diff.ObjectReflectDiff(expect, err)) t.Errorf("unexpected error on Raw(): %s", cmp.Diff(expect, err))
} }
}) })
} }
@@ -1220,7 +1219,7 @@ func TestRequestWatch(t *testing.T) {
t.Fatalf("Watch closed early, %d/%d read", i, len(testCase.Expect)) t.Fatalf("Watch closed early, %d/%d read", i, len(testCase.Expect))
} }
if !reflect.DeepEqual(evt, out) { if !reflect.DeepEqual(evt, out) {
t.Fatalf("Event %d does not match: %s", i, diff.ObjectReflectDiff(evt, out)) t.Fatalf("Event %d does not match: %s", i, cmp.Diff(evt, out))
} }
} }
} }

View File

@@ -26,10 +26,10 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/google/go-cmp/cmp"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api" clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest" clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest"
) )
@@ -248,7 +248,7 @@ preferences: {}
users: null users: null
`) `)
if !bytes.Equal(expected, data) { if !bytes.Equal(expected, data) {
t.Error(diff.ObjectReflectDiff(string(expected), string(data))) t.Error(cmp.Diff(string(expected), string(data)))
} }
} }

View File

@@ -21,9 +21,9 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
eventsv1 "k8s.io/api/events/v1" eventsv1 "k8s.io/api/events/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/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
) )
@@ -96,7 +96,7 @@ func TestRecordEventToSink(t *testing.T) {
recordedEvent := recordedEvents.Items[0] recordedEvent := recordedEvents.Items[0]
if !reflect.DeepEqual(recordedEvent, tc.expectedRecordedEvent) { if !reflect.DeepEqual(recordedEvent, tc.expectedRecordedEvent) {
t.Errorf("expected to have recorded Event: %#+v, got: %#+v\n diff: %s", tc.expectedRecordedEvent, recordedEvent, diff.ObjectReflectDiff(tc.expectedRecordedEvent, recordedEvent)) t.Errorf("expected to have recorded Event: %#+v, got: %#+v\n diff: %s", tc.expectedRecordedEvent, recordedEvent, cmp.Diff(tc.expectedRecordedEvent, recordedEvent))
} }
}) })
} }

View File

@@ -24,13 +24,13 @@ 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"
"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/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
fakeclient "k8s.io/client-go/testing" fakeclient "k8s.io/client-go/testing"
@@ -371,13 +371,13 @@ func TestLeaseSpecToLeaderElectionRecordRoundTrip(t *testing.T) {
newSpec := rl.LeaderElectionRecordToLeaseSpec(oldRecord) newSpec := rl.LeaderElectionRecordToLeaseSpec(oldRecord)
if !equality.Semantic.DeepEqual(oldSpec, newSpec) { if !equality.Semantic.DeepEqual(oldSpec, newSpec) {
t.Errorf("diff: %v", diff.ObjectReflectDiff(oldSpec, newSpec)) t.Errorf("diff: %v", cmp.Diff(oldSpec, newSpec))
} }
newRecord := rl.LeaseSpecToLeaderElectionRecord(&newSpec) newRecord := rl.LeaseSpecToLeaderElectionRecord(&newSpec)
if !equality.Semantic.DeepEqual(oldRecord, newRecord) { if !equality.Semantic.DeepEqual(oldRecord, newRecord) {
t.Errorf("diff: %v", diff.ObjectReflectDiff(oldRecord, newRecord)) t.Errorf("diff: %v", cmp.Diff(oldRecord, newRecord))
} }
} }

View File

@@ -25,13 +25,13 @@ import (
"time" "time"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1" corev1 "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"
fakeclientset "k8s.io/client-go/kubernetes/fake" fakeclientset "k8s.io/client-go/kubernetes/fake"
testcore "k8s.io/client-go/testing" testcore "k8s.io/client-go/testing"
@@ -260,7 +260,7 @@ func TestNewInformerWatcher(t *testing.T) {
sort.Sort(byEventTypeAndName(result)) sort.Sort(byEventTypeAndName(result))
if !reflect.DeepEqual(expected, result) { if !reflect.DeepEqual(expected, result) {
t.Error(spew.Errorf("\nexpected: %#v,\ngot: %#v,\ndiff: %s", expected, result, diff.ObjectReflectDiff(expected, result))) t.Error(spew.Errorf("\nexpected: %#v,\ngot: %#v,\ndiff: %s", expected, result, cmp.Diff(expected, result)))
return return
} }

View File

@@ -27,12 +27,12 @@ import (
"time" "time"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/google/go-cmp/cmp"
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/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
@@ -564,7 +564,7 @@ func TestRetryWatcher(t *testing.T) {
} }
if !reflect.DeepEqual(tc.expected, got) { if !reflect.DeepEqual(tc.expected, got) {
t.Fatal(spew.Errorf("expected %#+v, got %#+v;\ndiff: %s", tc.expected, got, diff.ObjectReflectDiff(tc.expected, got))) t.Fatal(spew.Errorf("expected %#+v, got %#+v;\ndiff: %s", tc.expected, got, cmp.Diff(tc.expected, got)))
} }
}) })
} }

View File

@@ -23,9 +23,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/go-cmp/cmp"
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
apiserver "k8s.io/apiserver/pkg/server" apiserver "k8s.io/apiserver/pkg/server"
apiserveroptions "k8s.io/apiserver/pkg/server/options" apiserveroptions "k8s.io/apiserver/pkg/server/options"
appconfig "k8s.io/cloud-provider/app/config" appconfig "k8s.io/cloud-provider/app/config"
@@ -150,7 +150,7 @@ func TestDefaultFlags(t *testing.T) {
NodeStatusUpdateFrequency: metav1.Duration{Duration: 5 * time.Minute}, NodeStatusUpdateFrequency: metav1.Duration{Duration: 5 * time.Minute},
} }
if !reflect.DeepEqual(expected, s) { if !reflect.DeepEqual(expected, s) {
t.Errorf("Got different run options than expected.\nDifference detected on:\n%s", diff.ObjectReflectDiff(expected, s)) t.Errorf("Got different run options than expected.\nDifference detected on:\n%s", cmp.Diff(expected, s))
} }
} }
@@ -309,7 +309,7 @@ func TestAddFlags(t *testing.T) {
NodeStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Minute}, NodeStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Minute},
} }
if !reflect.DeepEqual(expected, s) { if !reflect.DeepEqual(expected, s) {
t.Errorf("Got different run options than expected.\nDifference detected on:\n%s", diff.ObjectReflectDiff(expected, s)) t.Errorf("Got different run options than expected.\nDifference detected on:\n%s", cmp.Diff(expected, s))
} }
} }
@@ -444,6 +444,6 @@ func TestCreateConfig(t *testing.T) {
c.LoopbackClientConfig = nil c.LoopbackClientConfig = nil
if !reflect.DeepEqual(expected, c) { if !reflect.DeepEqual(expected, c) {
t.Errorf("Got different config than expected.\nDifference detected on:\n%s", diff.ObjectReflectDiff(expected, c)) t.Errorf("Got different config than expected.\nDifference detected on:\n%s", cmp.Diff(expected, c))
} }
} }

View File

@@ -20,12 +20,12 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
rbac "k8s.io/api/rbac/v1" rbac "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/apis/meta/v1" v1 "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/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions" "k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest/fake" "k8s.io/client-go/rest/fake"
@@ -150,7 +150,7 @@ func TestCreateRole(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if !equality.Semantic.DeepEqual(test.expectedRole, actual) { if !equality.Semantic.DeepEqual(test.expectedRole, actual) {
t.Errorf("%s", diff.ObjectReflectDiff(test.expectedRole, actual)) t.Errorf("%s", cmp.Diff(test.expectedRole, actual))
} }
}) })
} }

View File

@@ -22,6 +22,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
@@ -29,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kubectl/pkg/scheme" "k8s.io/kubectl/pkg/scheme"
) )
@@ -677,7 +677,7 @@ func TestSortingPrinter(t *testing.T) {
t.Fatalf("%s: expected error containing: %q, got none", tt.name, tt.expectedErr) t.Fatalf("%s: expected error containing: %q, got none", tt.name, tt.expectedErr)
} }
if !reflect.DeepEqual(table, expectedTable) { if !reflect.DeepEqual(table, expectedTable) {
t.Errorf("[%s]\nexpected/saw:\n%s", tt.name, diff.ObjectReflectDiff(expectedTable, table)) t.Errorf("[%s]\nexpected/saw:\n%s", tt.name, cmp.Diff(expectedTable, table))
} }
}) })
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {

View File

@@ -36,7 +36,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"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubectl/pkg/scheme" "k8s.io/kubectl/pkg/scheme"
"k8s.io/utils/exec" "k8s.io/utils/exec"
@@ -155,7 +154,7 @@ func TestMerge(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("testcase[%d], unexpected error: %v", i, err) t.Errorf("testcase[%d], unexpected error: %v", i, err)
} else if !apiequality.Semantic.DeepEqual(test.expected, out) { } else if !apiequality.Semantic.DeepEqual(test.expected, out) {
t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out)) t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, cmp.Diff(test.expected, out))
} }
} }
if test.expectErr && err == nil { if test.expectErr && err == nil {
@@ -238,7 +237,7 @@ func TestStrategicMerge(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("testcase[%d], unexpected error: %v", i, err) t.Errorf("testcase[%d], unexpected error: %v", i, err)
} else if !apiequality.Semantic.DeepEqual(test.expected, out) { } else if !apiequality.Semantic.DeepEqual(test.expected, out) {
t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out)) t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, cmp.Diff(test.expected, out))
} }
} }
if test.expectErr && err == nil { if test.expectErr && err == nil {
@@ -300,7 +299,7 @@ func TestJSONPatch(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("testcase[%d], unexpected error: %v", i, err) t.Errorf("testcase[%d], unexpected error: %v", i, err)
} else if !apiequality.Semantic.DeepEqual(test.expected, out) { } else if !apiequality.Semantic.DeepEqual(test.expected, out) {
t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out)) t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, cmp.Diff(test.expected, out))
} }
} }
if test.expectErr && err == nil { if test.expectErr && err == nil {

View File

@@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/google/go-cmp/cmp"
"github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
@@ -32,7 +33,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"
"k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
@@ -125,7 +125,7 @@ var _ = SIGDescribe("CustomResourceDefinition resources [Privileged:ClusterAdmin
framework.ExpectNotEqual(expected, nil) framework.ExpectNotEqual(expected, nil)
if !equality.Semantic.DeepEqual(actual.Spec, expected.Spec) { if !equality.Semantic.DeepEqual(actual.Spec, expected.Spec) {
framework.Failf("Expected CustomResourceDefinition in list with name %s to match crd created with same name, but got different specs:\n%s", framework.Failf("Expected CustomResourceDefinition in list with name %s to match crd created with same name, but got different specs:\n%s",
actual.Name, diff.ObjectReflectDiff(expected.Spec, actual.Spec)) actual.Name, cmp.Diff(expected.Spec, actual.Spec))
} }
} }
@@ -169,7 +169,7 @@ var _ = SIGDescribe("CustomResourceDefinition resources [Privileged:ClusterAdmin
framework.ExpectNoError(err, "getting CustomResourceDefinition status") framework.ExpectNoError(err, "getting CustomResourceDefinition status")
status := unstructuredToCRD(u) status := unstructuredToCRD(u)
if !equality.Semantic.DeepEqual(status.Spec, crd.Spec) { if !equality.Semantic.DeepEqual(status.Spec, crd.Spec) {
framework.Failf("Expected CustomResourceDefinition Spec to match status sub-resource Spec, but got:\n%s", diff.ObjectReflectDiff(status.Spec, crd.Spec)) framework.Failf("Expected CustomResourceDefinition Spec to match status sub-resource Spec, but got:\n%s", cmp.Diff(status.Spec, crd.Spec))
} }
status.Status.Conditions = append(status.Status.Conditions, updateCondition) status.Status.Conditions = append(status.Status.Conditions, updateCondition)
updated, err = apiExtensionClient.ApiextensionsV1().CustomResourceDefinitions().UpdateStatus(ctx, status, metav1.UpdateOptions{}) updated, err = apiExtensionClient.ApiextensionsV1().CustomResourceDefinitions().UpdateStatus(ctx, status, metav1.UpdateOptions{})

View File

@@ -25,7 +25,6 @@ import (
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"
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/wait" "k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
@@ -33,6 +32,7 @@ import (
testutils "k8s.io/kubernetes/test/utils" testutils "k8s.io/kubernetes/test/utils"
admissionapi "k8s.io/pod-security-admission/api" admissionapi "k8s.io/pod-security-admission/api"
"github.com/google/go-cmp/cmp"
"github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega" "github.com/onsi/gomega"
) )
@@ -159,7 +159,7 @@ var _ = SIGDescribe("NodeLease", func() {
if !apiequality.Semantic.DeepEqual(lastStatus, currentStatus) { if !apiequality.Semantic.DeepEqual(lastStatus, currentStatus) {
// heartbeat time changed, but there were relevant changes in the status, keep waiting // heartbeat time changed, but there were relevant changes in the status, keep waiting
framework.Logf("node status heartbeat changed in %s (with other status changes), waiting for %s", currentHeartbeatTime.Sub(lastHeartbeatTime), leaseDuration) framework.Logf("node status heartbeat changed in %s (with other status changes), waiting for %s", currentHeartbeatTime.Sub(lastHeartbeatTime), leaseDuration)
framework.Logf("%s", diff.ObjectReflectDiff(lastStatus, currentStatus)) framework.Logf("%s", cmp.Diff(lastStatus, currentStatus))
lastHeartbeatTime = currentHeartbeatTime lastHeartbeatTime = currentHeartbeatTime
lastObserved = currentObserved lastObserved = currentObserved
lastStatus = currentStatus lastStatus = currentStatus

View File

@@ -24,12 +24,12 @@ import (
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"
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/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/instrumentation/common" "k8s.io/kubernetes/test/e2e/instrumentation/common"
admissionapi "k8s.io/pod-security-admission/api" admissionapi "k8s.io/pod-security-admission/api"
"github.com/google/go-cmp/cmp"
"github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
) )
@@ -140,7 +140,7 @@ var _ = common.SIGDescribe("Events", func() {
event.ObjectMeta.ResourceVersion = "" event.ObjectMeta.ResourceVersion = ""
event.ObjectMeta.ManagedFields = nil event.ObjectMeta.ManagedFields = nil
if !apiequality.Semantic.DeepEqual(testEvent, event) { if !apiequality.Semantic.DeepEqual(testEvent, event) {
framework.Failf("test event wasn't properly updated: %v", diff.ObjectReflectDiff(testEvent, event)) framework.Failf("test event wasn't properly updated: %v", cmp.Diff(testEvent, event))
} }
ginkgo.By("deleting the test event") ginkgo.By("deleting the test event")

View File

@@ -26,7 +26,6 @@ import (
eventsv1 "k8s.io/api/events/v1" eventsv1 "k8s.io/api/events/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"
"k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/apimachinery/pkg/util/strategicpatch"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1" corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
typedeventsv1 "k8s.io/client-go/kubernetes/typed/events/v1" typedeventsv1 "k8s.io/client-go/kubernetes/typed/events/v1"
@@ -34,6 +33,7 @@ import (
"k8s.io/kubernetes/test/e2e/instrumentation/common" "k8s.io/kubernetes/test/e2e/instrumentation/common"
admissionapi "k8s.io/pod-security-admission/api" admissionapi "k8s.io/pod-security-admission/api"
"github.com/google/go-cmp/cmp"
"github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
) )
@@ -160,7 +160,7 @@ var _ = common.SIGDescribe("Events API", func() {
testEvent.Series = eventSeries testEvent.Series = eventSeries
if !apiequality.Semantic.DeepEqual(testEvent, event) { if !apiequality.Semantic.DeepEqual(testEvent, event) {
framework.Failf("test event wasn't properly patched: %v", diff.ObjectReflectDiff(testEvent, event)) framework.Failf("test event wasn't properly patched: %v", cmp.Diff(testEvent, event))
} }
ginkgo.By("updating the test event") ginkgo.By("updating the test event")
@@ -178,7 +178,7 @@ var _ = common.SIGDescribe("Events API", func() {
event.ObjectMeta.ResourceVersion = "" event.ObjectMeta.ResourceVersion = ""
event.ObjectMeta.ManagedFields = nil event.ObjectMeta.ManagedFields = nil
if !apiequality.Semantic.DeepEqual(testEvent, event) { if !apiequality.Semantic.DeepEqual(testEvent, event) {
framework.Failf("test event wasn't properly updated: %v", diff.ObjectReflectDiff(testEvent, event)) framework.Failf("test event wasn't properly updated: %v", cmp.Diff(testEvent, event))
} }
ginkgo.By("deleting the test event") ginkgo.By("deleting the test event")

View File

@@ -22,6 +22,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
v1 "k8s.io/api/admission/v1" v1 "k8s.io/api/admission/v1"
@@ -29,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/diff"
admissionfuzzer "k8s.io/kubernetes/pkg/apis/admission/fuzzer" admissionfuzzer "k8s.io/kubernetes/pkg/apis/admission/fuzzer"
) )
@@ -42,7 +42,7 @@ func TestConvertAdmissionRequestToV1(t *testing.T) {
converted := convertAdmissionRequestToV1(orig) converted := convertAdmissionRequestToV1(orig)
rt := convertAdmissionRequestToV1beta1(converted) rt := convertAdmissionRequestToV1beta1(converted)
if !reflect.DeepEqual(orig, rt) { if !reflect.DeepEqual(orig, rt) {
t.Errorf("expected all request fields to be in converted object but found unaccounted for differences, diff:\n%s", diff.ObjectReflectDiff(orig, converted)) t.Errorf("expected all request fields to be in converted object but found unaccounted for differences, diff:\n%s", cmp.Diff(orig, converted))
} }
}) })
} }
@@ -57,7 +57,7 @@ func TestConvertAdmissionResponseToV1beta1(t *testing.T) {
converted := convertAdmissionResponseToV1beta1(orig) converted := convertAdmissionResponseToV1beta1(orig)
rt := convertAdmissionResponseToV1(converted) rt := convertAdmissionResponseToV1(converted)
if !reflect.DeepEqual(orig, rt) { if !reflect.DeepEqual(orig, rt) {
t.Errorf("expected all fields to be in converted object but found unaccounted for differences, diff:\n%s", diff.ObjectReflectDiff(orig, converted)) t.Errorf("expected all fields to be in converted object but found unaccounted for differences, diff:\n%s", cmp.Diff(orig, converted))
} }
}) })
} }

View File

@@ -21,7 +21,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"k8s.io/apimachinery/pkg/util/diff" "github.com/google/go-cmp/cmp"
) )
func BenchmarkReplaceRegistryInImageURL(b *testing.B) { func BenchmarkReplaceRegistryInImageURL(b *testing.B) {
@@ -177,6 +177,6 @@ func TestGetMappedImageConfigs(t *testing.T) {
"docker.io/source/repo:1.0": "quay.io/repo/for-test:e2e-10-docker-io-source-repo-1-0-72R4aXm7YnxQ4_ek", "docker.io/source/repo:1.0": "quay.io/repo/for-test:e2e-10-docker-io-source-repo-1-0-72R4aXm7YnxQ4_ek",
} }
if !reflect.DeepEqual(expected, actual) { if !reflect.DeepEqual(expected, actual) {
t.Fatal(diff.ObjectReflectDiff(expected, actual)) t.Fatal(cmp.Diff(expected, actual))
} }
} }