Merge pull request #116896 from thockin/apimachinery_util_diff_cleanup
apimachinery util/diff cleanups
This commit is contained in:
commit
c3e3ff989a
@ -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"
|
||||||
@ -442,7 +442,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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,7 +641,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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@ package pod
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"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"
|
||||||
metavalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
metavalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/core/helper"
|
"k8s.io/kubernetes/pkg/apis/core/helper"
|
||||||
@ -850,7 +850,7 @@ func MarkPodProposedForResize(oldPod, newPod *api.Pod) {
|
|||||||
if c.Resources.Requests == nil {
|
if c.Resources.Requests == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if diff.ObjectDiff(oldPod.Spec.Containers[i].Resources, c.Resources) == "" {
|
if cmp.Equal(oldPod.Spec.Containers[i].Resources, c.Resources) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
findContainerStatus := func(css []api.ContainerStatus, cName string) (api.ContainerStatus, bool) {
|
findContainerStatus := func(css []api.ContainerStatus, cName string) (api.ContainerStatus, bool) {
|
||||||
@ -862,7 +862,7 @@ func MarkPodProposedForResize(oldPod, newPod *api.Pod) {
|
|||||||
return api.ContainerStatus{}, false
|
return api.ContainerStatus{}, false
|
||||||
}
|
}
|
||||||
if cs, ok := findContainerStatus(newPod.Status.ContainerStatuses, c.Name); ok {
|
if cs, ok := findContainerStatus(newPod.Status.ContainerStatuses, c.Name); ok {
|
||||||
if diff.ObjectDiff(c.Resources.Requests, cs.AllocatedResources) != "" {
|
if !cmp.Equal(c.Resources.Requests, cs.AllocatedResources) {
|
||||||
newPod.Status.Resize = api.PodResizeStatusProposed
|
newPod.Status.Resize = api.PodResizeStatusProposed
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -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()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -23,13 +23,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/gofuzz"
|
fuzz "github.com/google/gofuzz"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
|
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
|
||||||
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
|
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
|
||||||
"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/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ func doDeepCopyTest(t *testing.T, kind schema.GroupVersionKind, f *fuzz.Fuzzer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(prefuzzData.Bytes(), postfuzzData.Bytes()) {
|
if !bytes.Equal(prefuzzData.Bytes(), postfuzzData.Bytes()) {
|
||||||
t.Log(diff.StringDiff(prefuzzData.String(), postfuzzData.String()))
|
t.Log(cmp.Diff(prefuzzData.String(), postfuzzData.String()))
|
||||||
t.Errorf("Fuzzing copy modified original of %#v", kind)
|
t.Errorf("Fuzzing copy modified original of %#v", kind)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
||||||
@ -124,7 +124,7 @@ func TestHorizontalPodAutoscalerAnnotations(t *testing.T) {
|
|||||||
t.Fatalf("unexpected object: %v", obj)
|
t.Fatalf("unexpected object: %v", obj)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
|
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
|
||||||
t.Errorf("diff: %v", diff.ObjectDiff(*hpa, hpaBeforeMuatate))
|
t.Errorf("diff: %v", cmp.Diff(*hpa, hpaBeforeMuatate))
|
||||||
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
|
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
autoscalingv2 "k8s.io/api/autoscaling/v2"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -293,7 +293,7 @@ func TestHorizontalPodAutoscalerAnnotations(t *testing.T) {
|
|||||||
t.Fatalf("unexpected object: %v", obj)
|
t.Fatalf("unexpected object: %v", obj)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
|
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
|
||||||
t.Errorf("diff: %v", diff.ObjectDiff(*hpa, hpaBeforeMuatate))
|
t.Errorf("diff: %v", cmp.Diff(*hpa, hpaBeforeMuatate))
|
||||||
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
|
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1"
|
autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
@ -163,7 +162,7 @@ func TestHorizontalPodAutoscalerAnnotations(t *testing.T) {
|
|||||||
t.Fatalf("unexpected object: %v", obj)
|
t.Fatalf("unexpected object: %v", obj)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
|
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
|
||||||
t.Errorf("diff: %v", diff.ObjectDiff(*hpa, hpaBeforeMuatate))
|
t.Errorf("diff: %v", cmp.Diff(*hpa, hpaBeforeMuatate))
|
||||||
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
|
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -293,7 +293,7 @@ func TestHorizontalPodAutoscalerAnnotations(t *testing.T) {
|
|||||||
t.Fatalf("unexpected object: %v", obj)
|
t.Fatalf("unexpected object: %v", obj)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
|
if !reflect.DeepEqual(*hpa, hpaBeforeMuatate) {
|
||||||
t.Errorf("diff: %v", diff.ObjectDiff(*hpa, hpaBeforeMuatate))
|
t.Errorf("diff: %v", cmp.Diff(*hpa, hpaBeforeMuatate))
|
||||||
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
|
t.Errorf("expected: %#v\n actual: %#v", *hpa, hpaBeforeMuatate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
|
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
|
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
@ -383,7 +383,7 @@ func validateCertificateSigningRequestUpdate(newCSR, oldCSR *certificates.Certif
|
|||||||
case len(newConditions) > len(oldConditions):
|
case len(newConditions) > len(oldConditions):
|
||||||
validationErrorList = append(validationErrorList, field.Forbidden(field.NewPath("status", "conditions"), fmt.Sprintf("updates may not add a condition of type %q", t)))
|
validationErrorList = append(validationErrorList, field.Forbidden(field.NewPath("status", "conditions"), fmt.Sprintf("updates may not add a condition of type %q", t)))
|
||||||
case !apiequality.Semantic.DeepEqual(oldConditions, newConditions):
|
case !apiequality.Semantic.DeepEqual(oldConditions, newConditions):
|
||||||
conditionDiff := diff.ObjectDiff(oldConditions, newConditions)
|
conditionDiff := cmp.Diff(oldConditions, newConditions)
|
||||||
validationErrorList = append(validationErrorList, field.Forbidden(field.NewPath("status", "conditions"), fmt.Sprintf("updates may not modify a condition of type %q\n%v", t, conditionDiff)))
|
validationErrorList = append(validationErrorList, field.Forbidden(field.NewPath("status", "conditions"), fmt.Sprintf("updates may not modify a condition of type %q\n%v", t, conditionDiff)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"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"
|
||||||
@ -180,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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2113,7 +2113,7 @@ func TestSetDefaultResizePolicy(t *testing.T) {
|
|||||||
testPod.Spec.Containers = append(testPod.Spec.Containers, tc.testContainer)
|
testPod.Spec.Containers = append(testPod.Spec.Containers, tc.testContainer)
|
||||||
output := roundTrip(t, runtime.Object(&testPod))
|
output := roundTrip(t, runtime.Object(&testPod))
|
||||||
pod2 := output.(*v1.Pod)
|
pod2 := output.(*v1.Pod)
|
||||||
if diff.ObjectDiff(pod2.Spec.Containers[0].ResizePolicy, tc.expectedResizePolicy) != "" {
|
if !cmp.Equal(pod2.Spec.Containers[0].ResizePolicy, tc.expectedResizePolicy) {
|
||||||
t.Errorf("expected resize policy %+v, but got %+v", tc.expectedResizePolicy, pod2.Spec.Containers[0].ResizePolicy)
|
t.Errorf("expected resize policy %+v, but got %+v", tc.expectedResizePolicy, pod2.Spec.Containers[0].ResizePolicy)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -20,11 +20,11 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/apis/rbac"
|
"k8s.io/kubernetes/pkg/apis/rbac"
|
||||||
"k8s.io/kubernetes/pkg/apis/rbac/v1"
|
v1 "k8s.io/kubernetes/pkg/apis/rbac/v1"
|
||||||
|
|
||||||
// install RBAC types
|
// install RBAC types
|
||||||
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
||||||
@ -65,7 +65,7 @@ func TestHelpersRoundTrip(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(internalObj, roundTrippedObj) {
|
if !reflect.DeepEqual(internalObj, roundTrippedObj) {
|
||||||
t.Errorf("err on %T: got difference:\n%s", internalObj, diff.ObjectDiff(internalObj, roundTrippedObj))
|
t.Errorf("err on %T: got difference:\n%s", internalObj, cmp.Diff(internalObj, roundTrippedObj))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"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/util/diff"
|
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
corev1listers "k8s.io/client-go/listers/core/v1"
|
corev1listers "k8s.io/client-go/listers/core/v1"
|
||||||
@ -162,7 +162,7 @@ func TestConfigMapCreation(t *testing.T) {
|
|||||||
|
|
||||||
actions := client.Actions()
|
actions := client.Actions()
|
||||||
if reflect.DeepEqual(actions, tc.ExpectActions) {
|
if reflect.DeepEqual(actions, tc.ExpectActions) {
|
||||||
t.Errorf("Unexpected actions:\n%s", diff.ObjectGoPrintDiff(actions, tc.ExpectActions))
|
t.Errorf("Unexpected actions:\n%s", cmp.Diff(actions, tc.ExpectActions))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/yaml"
|
"k8s.io/apimachinery/pkg/util/yaml"
|
||||||
rbacv1ac "k8s.io/client-go/applyconfigurations/rbac/v1"
|
rbacv1ac "k8s.io/client-go/applyconfigurations/rbac/v1"
|
||||||
fakeclient "k8s.io/client-go/kubernetes/fake"
|
fakeclient "k8s.io/client-go/kubernetes/fake"
|
||||||
@ -215,7 +215,7 @@ func TestSyncClusterRole(t *testing.T) {
|
|||||||
t.Fatalf("error unmarshalling apply request: %v", err)
|
t.Fatalf("error unmarshalling apply request: %v", err)
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(ac, test.expectedClusterRoleApply) {
|
if !equality.Semantic.DeepEqual(ac, test.expectedClusterRoleApply) {
|
||||||
t.Fatalf("%v", diff.ObjectDiff(test.expectedClusterRoleApply, ac))
|
t.Fatalf("%v", cmp.Diff(test.expectedClusterRoleApply, ac))
|
||||||
}
|
}
|
||||||
if expectedActions == 2 {
|
if expectedActions == 2 {
|
||||||
action := fakeClient.Actions()[1]
|
action := fakeClient.Actions()[1]
|
||||||
@ -227,7 +227,7 @@ func TestSyncClusterRole(t *testing.T) {
|
|||||||
t.Fatalf("unexpected action %#v", action)
|
t.Fatalf("unexpected action %#v", action)
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(updateAction.GetObject().(*rbacv1.ClusterRole), test.expectedClusterRole) {
|
if !equality.Semantic.DeepEqual(updateAction.GetObject().(*rbacv1.ClusterRole), test.expectedClusterRole) {
|
||||||
t.Fatalf("%v", diff.ObjectDiff(test.expectedClusterRole, updateAction.GetObject().(*rbacv1.ClusterRole)))
|
t.Fatalf("%v", cmp.Diff(test.expectedClusterRole, updateAction.GetObject().(*rbacv1.ClusterRole)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -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)
|
||||||
|
@ -33,7 +33,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
appsinformers "k8s.io/client-go/informers/apps/v1"
|
appsinformers "k8s.io/client-go/informers/apps/v1"
|
||||||
coordinformers "k8s.io/client-go/informers/coordination/v1"
|
coordinformers "k8s.io/client-go/informers/coordination/v1"
|
||||||
@ -1250,10 +1249,10 @@ func TestMonitorNodeHealthUpdateStatus(t *testing.T) {
|
|||||||
t.Errorf("expected %v call, but got %v.", item.expectedRequestCount, item.fakeNodeHandler.RequestCount)
|
t.Errorf("expected %v call, but got %v.", item.expectedRequestCount, item.fakeNodeHandler.RequestCount)
|
||||||
}
|
}
|
||||||
if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) {
|
if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) {
|
||||||
t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
|
t.Errorf("Case[%d] unexpected nodes: %s", i, cmp.Diff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
|
||||||
}
|
}
|
||||||
if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) {
|
if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) {
|
||||||
t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
|
t.Errorf("Case[%d] unexpected nodes: %s", i, cmp.Diff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
podStatusUpdated := false
|
podStatusUpdated := false
|
||||||
@ -1800,10 +1799,10 @@ func TestMonitorNodeHealthUpdateNodeAndPodStatusWithLease(t *testing.T) {
|
|||||||
t.Errorf("expected %v call, but got %v.", item.expectedRequestCount, item.fakeNodeHandler.RequestCount)
|
t.Errorf("expected %v call, but got %v.", item.expectedRequestCount, item.fakeNodeHandler.RequestCount)
|
||||||
}
|
}
|
||||||
if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) {
|
if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) {
|
||||||
t.Errorf("unexpected nodes: %s", diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
|
t.Errorf("unexpected nodes: %s", cmp.Diff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
|
||||||
}
|
}
|
||||||
if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) {
|
if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !apiequality.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) {
|
||||||
t.Errorf("unexpected nodes: %s", diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
|
t.Errorf("unexpected nodes: %s", cmp.Diff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
podStatusUpdated := false
|
podStatusUpdated := false
|
||||||
|
@ -20,17 +20,18 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"k8s.io/klog/v2"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
@ -349,7 +350,7 @@ func (r *VolumeReactor) CheckVolumes(expectedVolumes []*v1.PersistentVolume) err
|
|||||||
if !reflect.DeepEqual(expectedMap, gotMap) {
|
if !reflect.DeepEqual(expectedMap, gotMap) {
|
||||||
// Print ugly but useful diff of expected and received objects for
|
// Print ugly but useful diff of expected and received objects for
|
||||||
// easier debugging.
|
// easier debugging.
|
||||||
return fmt.Errorf("Volume check failed [A-expected, B-got]: %s", diff.ObjectDiff(expectedMap, gotMap))
|
return fmt.Errorf("Volume check failed [A-expected, B-got]: %s", cmp.Diff(expectedMap, gotMap))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -378,7 +379,7 @@ func (r *VolumeReactor) CheckClaims(expectedClaims []*v1.PersistentVolumeClaim)
|
|||||||
if !reflect.DeepEqual(expectedMap, gotMap) {
|
if !reflect.DeepEqual(expectedMap, gotMap) {
|
||||||
// Print ugly but useful diff of expected and received objects for
|
// Print ugly but useful diff of expected and received objects for
|
||||||
// easier debugging.
|
// easier debugging.
|
||||||
return fmt.Errorf("Claim check failed [A-expected, B-got result]: %s", diff.ObjectDiff(expectedMap, gotMap))
|
return fmt.Errorf("Claim check failed [A-expected, B-got result]: %s", cmp.Diff(expectedMap, gotMap))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -25,11 +25,11 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
certificatesv1 "k8s.io/api/certificates/v1"
|
certificatesv1 "k8s.io/api/certificates/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
certificatesclient "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
|
certificatesclient "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
|
||||||
@ -278,10 +278,10 @@ users:
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(certConfig, test.expectedCertConfig) {
|
if !reflect.DeepEqual(certConfig, test.expectedCertConfig) {
|
||||||
t.Errorf("Unexpected certConfig: %s", diff.ObjectDiff(certConfig, test.expectedCertConfig))
|
t.Errorf("Unexpected certConfig: %s", cmp.Diff(certConfig, test.expectedCertConfig))
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(clientConfig, test.expectedClientConfig) {
|
if !reflect.DeepEqual(clientConfig, test.expectedClientConfig) {
|
||||||
t.Errorf("Unexpected clientConfig: %s", diff.ObjectDiff(clientConfig, test.expectedClientConfig))
|
t.Errorf("Unexpected clientConfig: %s", cmp.Diff(clientConfig, test.expectedClientConfig))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -341,7 +341,7 @@ users:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(config, expectedConfig) {
|
if !reflect.DeepEqual(config, expectedConfig) {
|
||||||
t.Errorf("Unexpected config: %s", diff.ObjectDiff(config, expectedConfig))
|
t.Errorf("Unexpected config: %s", cmp.Diff(config, expectedConfig))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -633,7 +632,7 @@ func TestAddAllocatableThresholds(t *testing.T) {
|
|||||||
for testName, testCase := range testCases {
|
for testName, testCase := range testCases {
|
||||||
t.Run(testName, func(t *testing.T) {
|
t.Run(testName, func(t *testing.T) {
|
||||||
if !thresholdsEqual(testCase.expected, addAllocatableThresholds(testCase.thresholds)) {
|
if !thresholdsEqual(testCase.expected, addAllocatableThresholds(testCase.thresholds)) {
|
||||||
t.Errorf("Err not as expected, test: %v, Unexpected data: %s", testName, diff.ObjectDiff(testCase.expected, addAllocatableThresholds(testCase.thresholds)))
|
t.Errorf("Err not as expected, test: %v, Unexpected data: %s", testName, cmp.Diff(testCase.expected, addAllocatableThresholds(testCase.thresholds)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
libcontaineruserns "github.com/opencontainers/runc/libcontainer/userns"
|
libcontaineruserns "github.com/opencontainers/runc/libcontainer/userns"
|
||||||
"github.com/opencontainers/selinux/go-selinux"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
@ -47,7 +48,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
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"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@ -2602,8 +2602,7 @@ func isPodResizeInProgress(pod *v1.Pod, podStatus *v1.PodStatus) bool {
|
|||||||
if cs.Resources == nil {
|
if cs.Resources == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if diff.ObjectDiff(c.Resources.Limits, cs.Resources.Limits) != "" ||
|
if !cmp.Equal(c.Resources.Limits, cs.Resources.Limits) || !cmp.Equal(cs.AllocatedResources, cs.Resources.Requests) {
|
||||||
diff.ObjectDiff(cs.AllocatedResources, cs.Resources.Requests) != "" {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2673,7 +2672,7 @@ func (kl *Kubelet) handlePodResourcesResize(pod *v1.Pod) *v1.Pod {
|
|||||||
klog.V(5).InfoS("ContainerStatus.AllocatedResources length mismatch", "pod", pod.Name, "container", container.Name)
|
klog.V(5).InfoS("ContainerStatus.AllocatedResources length mismatch", "pod", pod.Name, "container", container.Name)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if len(diff.ObjectDiff(container.Resources.Requests, containerStatus.AllocatedResources)) > 0 {
|
if !cmp.Equal(container.Resources.Requests, containerStatus.AllocatedResources) {
|
||||||
podResized = true
|
podResized = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,13 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"k8s.io/apimachinery/pkg/util/strategicpatch"
|
"k8s.io/apimachinery/pkg/util/strategicpatch"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
@ -310,7 +310,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
|
|||||||
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
|
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
|
||||||
"NotReady should be last")
|
"NotReady should be last")
|
||||||
assert.Len(t, updatedNode.Status.Images, len(expectedImageList))
|
assert.Len(t, updatedNode.Status.Images, len(expectedImageList))
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode))
|
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,7 +504,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
|
|||||||
// Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961
|
// Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961
|
||||||
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
|
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
|
||||||
"NodeReady should be the last condition")
|
"NodeReady should be the last condition")
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode))
|
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateExistingNodeStatusTimeout(t *testing.T) {
|
func TestUpdateExistingNodeStatusTimeout(t *testing.T) {
|
||||||
@ -714,7 +714,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
|
|||||||
LastHeartbeatTime: metav1.Time{},
|
LastHeartbeatTime: metav1.Time{},
|
||||||
LastTransitionTime: metav1.Time{},
|
LastTransitionTime: metav1.Time{},
|
||||||
}
|
}
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode))
|
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(random-liu): Refactor the unit test to be table driven test.
|
// TODO(random-liu): Refactor the unit test to be table driven test.
|
||||||
@ -931,7 +931,7 @@ func TestUpdateNodeStatusWithLease(t *testing.T) {
|
|||||||
cond.LastHeartbeatTime = cond.LastHeartbeatTime.Rfc3339Copy()
|
cond.LastHeartbeatTime = cond.LastHeartbeatTime.Rfc3339Copy()
|
||||||
cond.LastTransitionTime = cond.LastTransitionTime.Rfc3339Copy()
|
cond.LastTransitionTime = cond.LastTransitionTime.Rfc3339Copy()
|
||||||
}
|
}
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode))
|
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
|
||||||
|
|
||||||
// Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961
|
// Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961
|
||||||
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
|
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[len(updatedNode.Status.Conditions)-1].Type,
|
||||||
@ -960,7 +960,7 @@ func TestUpdateNodeStatusWithLease(t *testing.T) {
|
|||||||
for i, cond := range expectedNode.Status.Conditions {
|
for i, cond := range expectedNode.Status.Conditions {
|
||||||
expectedNode.Status.Conditions[i].LastHeartbeatTime = metav1.NewTime(cond.LastHeartbeatTime.Time.Add(time.Minute)).Rfc3339Copy()
|
expectedNode.Status.Conditions[i].LastHeartbeatTime = metav1.NewTime(cond.LastHeartbeatTime.Time.Add(time.Minute)).Rfc3339Copy()
|
||||||
}
|
}
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode))
|
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode, updatedNode), "%s", cmp.Diff(expectedNode, updatedNode))
|
||||||
|
|
||||||
// Update node status again when nothing is changed (except heartbeat time).
|
// Update node status again when nothing is changed (except heartbeat time).
|
||||||
// Do not report node status if it is within the duration of nodeStatusReportFrequency.
|
// Do not report node status if it is within the duration of nodeStatusReportFrequency.
|
||||||
@ -1122,14 +1122,14 @@ func TestUpdateNodeStatusAndVolumesInUseWithNodeLease(t *testing.T) {
|
|||||||
|
|
||||||
updatedNode, err := applyNodeStatusPatch(tc.existingNode, patchAction.GetPatch())
|
updatedNode, err := applyNodeStatusPatch(tc.existingNode, patchAction.GetPatch())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectedNode, updatedNode), "%s", diff.ObjectDiff(tc.expectedNode, updatedNode))
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectedNode, updatedNode), "%s", cmp.Diff(tc.expectedNode, updatedNode))
|
||||||
} else {
|
} else {
|
||||||
assert.Len(t, actions, 1)
|
assert.Len(t, actions, 1)
|
||||||
assert.IsType(t, core.GetActionImpl{}, actions[0])
|
assert.IsType(t, core.GetActionImpl{}, actions[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
reportedInUse := fakeVolumeManager.GetVolumesReportedInUse()
|
reportedInUse := fakeVolumeManager.GetVolumesReportedInUse()
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectedReportedInUse, reportedInUse), "%s", diff.ObjectDiff(tc.expectedReportedInUse, reportedInUse))
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectedReportedInUse, reportedInUse), "%s", cmp.Diff(tc.expectedReportedInUse, reportedInUse))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1572,7 +1572,7 @@ func TestUpdateNewNodeStatusTooLargeReservation(t *testing.T) {
|
|||||||
|
|
||||||
updatedNode, err := applyNodeStatusPatch(&existingNode, actions[1].(core.PatchActionImpl).GetPatch())
|
updatedNode, err := applyNodeStatusPatch(&existingNode, actions[1].(core.PatchActionImpl).GetPatch())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode.Status.Allocatable, updatedNode.Status.Allocatable), "%s", diff.ObjectDiff(expectedNode.Status.Allocatable, updatedNode.Status.Allocatable))
|
assert.True(t, apiequality.Semantic.DeepEqual(expectedNode.Status.Allocatable, updatedNode.Status.Allocatable), "%s", cmp.Diff(expectedNode.Status.Allocatable, updatedNode.Status.Allocatable))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateDefaultLabels(t *testing.T) {
|
func TestUpdateDefaultLabels(t *testing.T) {
|
||||||
@ -2857,8 +2857,8 @@ func TestNodeStatusHasChanged(t *testing.T) {
|
|||||||
statusCopy := tc.status.DeepCopy()
|
statusCopy := tc.status.DeepCopy()
|
||||||
changed := nodeStatusHasChanged(tc.originalStatus, tc.status)
|
changed := nodeStatusHasChanged(tc.originalStatus, tc.status)
|
||||||
assert.Equal(t, tc.expectChange, changed, "Expect node status change to be %t, but got %t.", tc.expectChange, changed)
|
assert.Equal(t, tc.expectChange, changed, "Expect node status change to be %t, but got %t.", tc.expectChange, changed)
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(originalStatusCopy, tc.originalStatus), "%s", diff.ObjectDiff(originalStatusCopy, tc.originalStatus))
|
assert.True(t, apiequality.Semantic.DeepEqual(originalStatusCopy, tc.originalStatus), "%s", cmp.Diff(originalStatusCopy, tc.originalStatus))
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(statusCopy, tc.status), "%s", diff.ObjectDiff(statusCopy, tc.status))
|
assert.True(t, apiequality.Semantic.DeepEqual(statusCopy, tc.status), "%s", cmp.Diff(statusCopy, tc.status))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3012,7 +3012,7 @@ func TestUpdateNodeAddresses(t *testing.T) {
|
|||||||
updatedNode, err := applyNodeStatusPatch(oldNode, patchAction.GetPatch())
|
updatedNode, err := applyNodeStatusPatch(oldNode, patchAction.GetPatch())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(updatedNode, expectedNode), "%s", diff.ObjectDiff(expectedNode, updatedNode))
|
assert.True(t, apiequality.Semantic.DeepEqual(updatedNode, expectedNode), "%s", cmp.Diff(expectedNode, updatedNode))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"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/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
|
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
@ -1500,7 +1500,7 @@ func (kl *Kubelet) determinePodResizeStatus(pod *v1.Pod, podStatus *v1.PodStatus
|
|||||||
specStatusDiffer := false
|
specStatusDiffer := false
|
||||||
for _, c := range pod.Spec.Containers {
|
for _, c := range pod.Spec.Containers {
|
||||||
if cs, ok := podutil.GetContainerStatus(podStatus.ContainerStatuses, c.Name); ok {
|
if cs, ok := podutil.GetContainerStatus(podStatus.ContainerStatuses, c.Name); ok {
|
||||||
if cs.Resources != nil && diff.ObjectDiff(c.Resources, *cs.Resources) != "" {
|
if cs.Resources != nil && !cmp.Equal(c.Resources, *cs.Resources) {
|
||||||
specStatusDiffer = true
|
specStatusDiffer = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,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"
|
|
||||||
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"
|
||||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
@ -882,7 +881,7 @@ func TestGenerateLinuxContainerResources(t *testing.T) {
|
|||||||
}
|
}
|
||||||
resources := m.generateLinuxContainerResources(pod, &pod.Spec.Containers[0], false)
|
resources := m.generateLinuxContainerResources(pod, &pod.Spec.Containers[0], false)
|
||||||
tc.expected.HugepageLimits = resources.HugepageLimits
|
tc.expected.HugepageLimits = resources.HugepageLimits
|
||||||
if diff.ObjectDiff(resources, tc.expected) != "" {
|
if !cmp.Equal(resources, tc.expected) {
|
||||||
t.Errorf("Test %s: expected resources %+v, but got %+v", tc.name, tc.expected, resources)
|
t.Errorf("Test %s: expected resources %+v, but got %+v", tc.name, tc.expected, resources)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
crierror "k8s.io/cri-api/pkg/errors"
|
crierror "k8s.io/cri-api/pkg/errors"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
@ -34,7 +35,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"
|
||||||
kubetypes "k8s.io/apimachinery/pkg/types"
|
kubetypes "k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
utilversion "k8s.io/apimachinery/pkg/util/version"
|
utilversion "k8s.io/apimachinery/pkg/util/version"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
@ -553,7 +553,7 @@ func (m *kubeGenericRuntimeManager) computePodResizeAction(pod *v1.Pod, containe
|
|||||||
if !exists || apiContainerStatus.State.Running == nil || apiContainerStatus.Resources == nil ||
|
if !exists || apiContainerStatus.State.Running == nil || apiContainerStatus.Resources == nil ||
|
||||||
kubeContainerStatus.State != kubecontainer.ContainerStateRunning ||
|
kubeContainerStatus.State != kubecontainer.ContainerStateRunning ||
|
||||||
kubeContainerStatus.ID.String() != apiContainerStatus.ContainerID ||
|
kubeContainerStatus.ID.String() != apiContainerStatus.ContainerID ||
|
||||||
len(diff.ObjectDiff(container.Resources.Requests, apiContainerStatus.AllocatedResources)) != 0 {
|
!cmp.Equal(container.Resources.Requests, apiContainerStatus.AllocatedResources) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,12 +27,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisorapiv1 "github.com/google/cadvisor/info/v1"
|
cadvisorapiv1 "github.com/google/cadvisor/info/v1"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
cloudprovider "k8s.io/cloud-provider"
|
cloudprovider "k8s.io/cloud-provider"
|
||||||
@ -579,10 +579,10 @@ func TestNodeAddress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAddresses, existingNode.Status.Addresses),
|
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAddresses, existingNode.Status.Addresses),
|
||||||
"Diff: %s", diff.ObjectDiff(testCase.expectedAddresses, existingNode.Status.Addresses))
|
"Diff: %s", cmp.Diff(testCase.expectedAddresses, existingNode.Status.Addresses))
|
||||||
if testCase.expectedAnnotations != nil {
|
if testCase.expectedAnnotations != nil {
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAnnotations, existingNode.Annotations),
|
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAnnotations, existingNode.Annotations),
|
||||||
"Diff: %s", diff.ObjectDiff(testCase.expectedAnnotations, existingNode.Annotations))
|
"Diff: %s", cmp.Diff(testCase.expectedAnnotations, existingNode.Annotations))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -667,7 +667,7 @@ func TestNodeAddress_NoCloudProvider(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAddresses, existingNode.Status.Addresses),
|
assert.True(t, apiequality.Semantic.DeepEqual(testCase.expectedAddresses, existingNode.Status.Addresses),
|
||||||
"Diff: %s", diff.ObjectDiff(testCase.expectedAddresses, existingNode.Status.Addresses))
|
"Diff: %s", cmp.Diff(testCase.expectedAddresses, existingNode.Status.Addresses))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1149,7 +1149,7 @@ func TestMachineInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// check expected node
|
// check expected node
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.node),
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.node),
|
||||||
"Diff: %s", diff.ObjectDiff(tc.expectNode, tc.node))
|
"Diff: %s", cmp.Diff(tc.expectNode, tc.node))
|
||||||
// check expected events
|
// check expected events
|
||||||
require.Equal(t, len(tc.expectEvents), len(events))
|
require.Equal(t, len(tc.expectEvents), len(events))
|
||||||
for i := range tc.expectEvents {
|
for i := range tc.expectEvents {
|
||||||
@ -1239,7 +1239,7 @@ func TestVersionInfo(t *testing.T) {
|
|||||||
require.Equal(t, tc.expectError, err)
|
require.Equal(t, tc.expectError, err)
|
||||||
// check expected node
|
// check expected node
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.node),
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.node),
|
||||||
"Diff: %s", diff.ObjectDiff(tc.expectNode, tc.node))
|
"Diff: %s", cmp.Diff(tc.expectNode, tc.node))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1319,7 +1319,7 @@ func TestImages(t *testing.T) {
|
|||||||
expectNode.Status.Images = makeExpectedImageList(tc.imageList, tc.maxImages, MaxNamesPerImageInNodeStatus)
|
expectNode.Status.Images = makeExpectedImageList(tc.imageList, tc.maxImages, MaxNamesPerImageInNodeStatus)
|
||||||
}
|
}
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(expectNode, node),
|
assert.True(t, apiequality.Semantic.DeepEqual(expectNode, node),
|
||||||
"Diff: %s", diff.ObjectDiff(expectNode, node))
|
"Diff: %s", cmp.Diff(expectNode, node))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1510,7 +1510,7 @@ func TestReadyCondition(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// check expected condition
|
// check expected condition
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
|
||||||
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions))
|
"Diff: %s", cmp.Diff(tc.expectConditions, tc.node.Status.Conditions))
|
||||||
// check expected events
|
// check expected events
|
||||||
require.Equal(t, len(tc.expectEvents), len(events))
|
require.Equal(t, len(tc.expectEvents), len(events))
|
||||||
for i := range tc.expectEvents {
|
for i := range tc.expectEvents {
|
||||||
@ -1632,7 +1632,7 @@ func TestMemoryPressureCondition(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// check expected condition
|
// check expected condition
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
|
||||||
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions))
|
"Diff: %s", cmp.Diff(tc.expectConditions, tc.node.Status.Conditions))
|
||||||
// check expected events
|
// check expected events
|
||||||
require.Equal(t, len(tc.expectEvents), len(events))
|
require.Equal(t, len(tc.expectEvents), len(events))
|
||||||
for i := range tc.expectEvents {
|
for i := range tc.expectEvents {
|
||||||
@ -1754,7 +1754,7 @@ func TestPIDPressureCondition(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// check expected condition
|
// check expected condition
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
|
||||||
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions))
|
"Diff: %s", cmp.Diff(tc.expectConditions, tc.node.Status.Conditions))
|
||||||
// check expected events
|
// check expected events
|
||||||
require.Equal(t, len(tc.expectEvents), len(events))
|
require.Equal(t, len(tc.expectEvents), len(events))
|
||||||
for i := range tc.expectEvents {
|
for i := range tc.expectEvents {
|
||||||
@ -1876,7 +1876,7 @@ func TestDiskPressureCondition(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// check expected condition
|
// check expected condition
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectConditions, tc.node.Status.Conditions),
|
||||||
"Diff: %s", diff.ObjectDiff(tc.expectConditions, tc.node.Status.Conditions))
|
"Diff: %s", cmp.Diff(tc.expectConditions, tc.node.Status.Conditions))
|
||||||
// check expected events
|
// check expected events
|
||||||
require.Equal(t, len(tc.expectEvents), len(events))
|
require.Equal(t, len(tc.expectEvents), len(events))
|
||||||
for i := range tc.expectEvents {
|
for i := range tc.expectEvents {
|
||||||
@ -1933,7 +1933,7 @@ func TestVolumesInUse(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// check expected volumes
|
// check expected volumes
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectVolumesInUse, tc.node.Status.VolumesInUse),
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectVolumesInUse, tc.node.Status.VolumesInUse),
|
||||||
"Diff: %s", diff.ObjectDiff(tc.expectVolumesInUse, tc.node.Status.VolumesInUse))
|
"Diff: %s", cmp.Diff(tc.expectVolumesInUse, tc.node.Status.VolumesInUse))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1997,7 +1997,7 @@ func TestVolumeLimits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// check expected node
|
// check expected node
|
||||||
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, node),
|
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, node),
|
||||||
"Diff: %s", diff.ObjectDiff(tc.expectNode, node))
|
"Diff: %s", cmp.Diff(tc.expectNode, node))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/component-base/metrics/testutil"
|
"k8s.io/component-base/metrics/testutil"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
|
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
|
||||||
@ -101,7 +101,7 @@ func verifyEvents(t *testing.T, expected, actual []*PodLifecycleEvent) {
|
|||||||
sort.Sort(sortableEvents(expected))
|
sort.Sort(sortableEvents(expected))
|
||||||
sort.Sort(sortableEvents(actual))
|
sort.Sort(sortableEvents(actual))
|
||||||
if !reflect.DeepEqual(expected, actual) {
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
t.Errorf("Actual events differ from the expected; diff:\n %v", diff.ObjectDiff(expected, actual))
|
t.Errorf("Actual events differ from the expected; diff:\n %v", cmp.Diff(expected, actual))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
@ -32,7 +33,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
@ -937,7 +937,7 @@ func (m *manager) needsReconcile(uid types.UID, status v1.PodStatus) bool {
|
|||||||
}
|
}
|
||||||
klog.V(3).InfoS("Pod status is inconsistent with cached status for pod, a reconciliation should be triggered",
|
klog.V(3).InfoS("Pod status is inconsistent with cached status for pod, a reconciliation should be triggered",
|
||||||
"pod", klog.KObj(pod),
|
"pod", klog.KObj(pod),
|
||||||
"statusDiff", diff.ObjectDiff(podStatus, &status))
|
"statusDiff", cmp.Diff(podStatus, &status))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -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.")
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
@ -242,7 +242,7 @@ func TestScaleGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
got := obj.(*autoscaling.Scale)
|
got := obj.(*autoscaling.Scale)
|
||||||
if !apiequality.Semantic.DeepEqual(want, got) {
|
if !apiequality.Semantic.DeepEqual(want, got) {
|
||||||
t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got))
|
t.Errorf("unexpected scale: %s", cmp.Diff(want, got))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -297,7 +297,7 @@ func TestScaleGet(t *testing.T) {
|
|||||||
t.Fatalf("error fetching scale for %s: %v", name, err)
|
t.Fatalf("error fetching scale for %s: %v", name, err)
|
||||||
}
|
}
|
||||||
if !apiequality.Semantic.DeepEqual(got, want) {
|
if !apiequality.Semantic.DeepEqual(got, want) {
|
||||||
t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want))
|
t.Errorf("unexpected scale: %s", cmp.Diff(got, want))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -247,7 +247,7 @@ func TestScaleGet(t *testing.T) {
|
|||||||
t.Fatalf("error fetching scale for %s: %v", name, err)
|
t.Fatalf("error fetching scale for %s: %v", name, err)
|
||||||
}
|
}
|
||||||
if !apiequality.Semantic.DeepEqual(got, want) {
|
if !apiequality.Semantic.DeepEqual(got, want) {
|
||||||
t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want))
|
t.Errorf("unexpected scale: %s", cmp.Diff(got, want))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,16 +19,17 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
|
|
||||||
// Ensure that autoscaling/v1 package is initialized.
|
// Ensure that autoscaling/v1 package is initialized.
|
||||||
_ "k8s.io/api/autoscaling/v1"
|
_ "k8s.io/api/autoscaling/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -211,6 +212,6 @@ func TestUpdateStatus(t *testing.T) {
|
|||||||
autoscalerOut := obj.(*autoscaling.HorizontalPodAutoscaler)
|
autoscalerOut := obj.(*autoscaling.HorizontalPodAutoscaler)
|
||||||
// only compare the meaningful update b/c we can't compare due to metadata
|
// only compare the meaningful update b/c we can't compare due to metadata
|
||||||
if !apiequality.Semantic.DeepEqual(autoscalerIn.Status, autoscalerOut.Status) {
|
if !apiequality.Semantic.DeepEqual(autoscalerIn.Status, autoscalerOut.Status) {
|
||||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(autoscalerIn, autoscalerOut))
|
t.Errorf("unexpected object: %s", cmp.Diff(autoscalerIn, autoscalerOut))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
certapi "k8s.io/kubernetes/pkg/apis/certificates"
|
certapi "k8s.io/kubernetes/pkg/apis/certificates"
|
||||||
@ -137,7 +137,7 @@ func TestStrategyCreate(t *testing.T) {
|
|||||||
obj := tc.obj
|
obj := tc.obj
|
||||||
Strategy.PrepareForCreate(tc.ctx, obj)
|
Strategy.PrepareForCreate(tc.ctx, obj)
|
||||||
if !reflect.DeepEqual(obj, tc.expectedObj) {
|
if !reflect.DeepEqual(obj, tc.expectedObj) {
|
||||||
t.Errorf("object diff: %s", diff.ObjectDiff(obj, tc.expectedObj))
|
t.Errorf("object diff: %s", cmp.Diff(obj, tc.expectedObj))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@ func TestStatusUpdate(t *testing.T) {
|
|||||||
obj := tt.newObj.DeepCopy()
|
obj := tt.newObj.DeepCopy()
|
||||||
StatusStrategy.PrepareForUpdate(context.TODO(), obj, tt.oldObj.DeepCopy())
|
StatusStrategy.PrepareForUpdate(context.TODO(), obj, tt.oldObj.DeepCopy())
|
||||||
if !reflect.DeepEqual(obj, tt.expectedObj) {
|
if !reflect.DeepEqual(obj, tt.expectedObj) {
|
||||||
t.Errorf("object diff: %s", diff.ObjectDiff(obj, tt.expectedObj))
|
t.Errorf("object diff: %s", cmp.Diff(obj, tt.expectedObj))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
@ -30,7 +31,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/probe"
|
"k8s.io/kubernetes/pkg/probe"
|
||||||
@ -87,7 +87,7 @@ func TestList_NoError(t *testing.T) {
|
|||||||
Items: []api.ComponentStatus{*(createTestStatus("test1", api.ConditionTrue, "ok", ""))},
|
Items: []api.ComponentStatus{*(createTestStatus("test1", api.ConditionTrue, "ok", ""))},
|
||||||
}
|
}
|
||||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ func TestList_WithLabelSelectors(t *testing.T) {
|
|||||||
Items: []api.ComponentStatus{},
|
Items: []api.ComponentStatus{},
|
||||||
}
|
}
|
||||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ func TestList_WithFieldSelectors(t *testing.T) {
|
|||||||
Items: []api.ComponentStatus{},
|
Items: []api.ComponentStatus{},
|
||||||
}
|
}
|
||||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ func TestList_FailedCheck(t *testing.T) {
|
|||||||
*(createTestStatus("test1", api.ConditionFalse, "", ""))},
|
*(createTestStatus("test1", api.ConditionFalse, "", ""))},
|
||||||
}
|
}
|
||||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ func TestList_UnknownError(t *testing.T) {
|
|||||||
*(createTestStatus("test1", api.ConditionUnknown, "", "fizzbuzz error"))},
|
*(createTestStatus("test1", api.ConditionUnknown, "", "fizzbuzz error"))},
|
||||||
}
|
}
|
||||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ func TestGet_NoError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
expect := createTestStatus("test1", api.ConditionTrue, "ok", "")
|
expect := createTestStatus("test1", api.ConditionTrue, "ok", "")
|
||||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
t.Errorf("Got unexpected object. Diff: %s", cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
apitesting "k8s.io/kubernetes/pkg/api/testing"
|
apitesting "k8s.io/kubernetes/pkg/api/testing"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ func TestGetAttrs(t *testing.T) {
|
|||||||
"type": api.EventTypeNormal,
|
"type": api.EventTypeNormal,
|
||||||
}
|
}
|
||||||
if e, a := expectA, field; !reflect.DeepEqual(e, a) {
|
if e, a := expectA, field; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("diff: %s", diff.ObjectDiff(e, a))
|
t.Errorf("diff: %s", cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
|
|
||||||
eventB := &api.Event{
|
eventB := &api.Event{
|
||||||
@ -105,7 +105,7 @@ func TestGetAttrs(t *testing.T) {
|
|||||||
"type": api.EventTypeNormal,
|
"type": api.EventTypeNormal,
|
||||||
}
|
}
|
||||||
if e, a := expectB, field; !reflect.DeepEqual(e, a) {
|
if e, a := expectB, field; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("diff: %s", diff.ObjectDiff(e, a))
|
t.Errorf("diff: %s", cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -197,7 +197,7 @@ func TestUpdateStatus(t *testing.T) {
|
|||||||
pvOut := obj.(*api.PersistentVolume)
|
pvOut := obj.(*api.PersistentVolume)
|
||||||
// only compare the relevant change b/c metadata will differ
|
// only compare the relevant change b/c metadata will differ
|
||||||
if !apiequality.Semantic.DeepEqual(pvIn.Status, pvOut.Status) {
|
if !apiequality.Semantic.DeepEqual(pvIn.Status, pvOut.Status) {
|
||||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(pvIn.Status, pvOut.Status))
|
t.Errorf("unexpected object: %s", cmp.Diff(pvIn.Status, pvOut.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -200,7 +200,7 @@ func TestUpdateStatus(t *testing.T) {
|
|||||||
pvcOut := obj.(*api.PersistentVolumeClaim)
|
pvcOut := obj.(*api.PersistentVolumeClaim)
|
||||||
// only compare relevant changes b/c of difference in metadata
|
// only compare relevant changes b/c of difference in metadata
|
||||||
if !apiequality.Semantic.DeepEqual(pvc.Status, pvcOut.Status) {
|
if !apiequality.Semantic.DeepEqual(pvc.Status, pvcOut.Status) {
|
||||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(pvc.Status, pvcOut.Status))
|
t.Errorf("unexpected object: %s", cmp.Diff(pvc.Status, pvcOut.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
@ -33,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"
|
||||||
@ -609,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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1074,7 +1074,7 @@ func TestEtcdUpdateNotScheduled(t *testing.T) {
|
|||||||
podOut := obj.(*api.Pod)
|
podOut := obj.(*api.Pod)
|
||||||
// validChangedPod only changes the Labels, so were checking the update was valid
|
// validChangedPod only changes the Labels, so were checking the update was valid
|
||||||
if !apiequality.Semantic.DeepEqual(podIn.Labels, podOut.Labels) {
|
if !apiequality.Semantic.DeepEqual(podIn.Labels, podOut.Labels) {
|
||||||
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn))
|
t.Errorf("objects differ: %v", cmp.Diff(podOut, podIn))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,7 +1147,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
|
|||||||
podOut := obj.(*api.Pod)
|
podOut := obj.(*api.Pod)
|
||||||
// Check to verify the Spec and Label updates match from change above. Those are the fields changed.
|
// Check to verify the Spec and Label updates match from change above. Those are the fields changed.
|
||||||
if !apiequality.Semantic.DeepEqual(podOut.Spec, podIn.Spec) || !apiequality.Semantic.DeepEqual(podOut.Labels, podIn.Labels) {
|
if !apiequality.Semantic.DeepEqual(podOut.Spec, podIn.Spec) || !apiequality.Semantic.DeepEqual(podOut.Labels, podIn.Labels) {
|
||||||
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn))
|
t.Errorf("objects differ: %v", cmp.Diff(podOut, podIn))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1262,7 +1262,7 @@ func TestEtcdUpdateStatus(t *testing.T) {
|
|||||||
if !apiequality.Semantic.DeepEqual(podOut.Spec, expected.Spec) ||
|
if !apiequality.Semantic.DeepEqual(podOut.Spec, expected.Spec) ||
|
||||||
!apiequality.Semantic.DeepEqual(podOut.Labels, expected.Labels) ||
|
!apiequality.Semantic.DeepEqual(podOut.Labels, expected.Labels) ||
|
||||||
!apiequality.Semantic.DeepEqual(podOut.Status, expected.Status) {
|
!apiequality.Semantic.DeepEqual(podOut.Status, expected.Status) {
|
||||||
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, expected))
|
t.Errorf("objects differ: %v", cmp.Diff(podOut, expected))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -294,7 +294,7 @@ func TestScaleGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
got := obj.(*autoscaling.Scale)
|
got := obj.(*autoscaling.Scale)
|
||||||
if !apiequality.Semantic.DeepEqual(want, got) {
|
if !apiequality.Semantic.DeepEqual(want, got) {
|
||||||
t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got))
|
t.Errorf("unexpected scale: %s", cmp.Diff(want, got))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -206,7 +206,7 @@ func TestUpdateStatus(t *testing.T) {
|
|||||||
rqOut := obj.(*api.ResourceQuota)
|
rqOut := obj.(*api.ResourceQuota)
|
||||||
// only compare the meaningful update b/c we can't compare due to metadata
|
// only compare the meaningful update b/c we can't compare due to metadata
|
||||||
if !apiequality.Semantic.DeepEqual(resourcequotaIn.Status, rqOut.Status) {
|
if !apiequality.Semantic.DeepEqual(resourcequotaIn.Status, rqOut.Status) {
|
||||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(resourcequotaIn, rqOut))
|
t.Errorf("unexpected object: %s", cmp.Diff(resourcequotaIn, rqOut))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ func TestDefaultRuleResolver(t *testing.T) {
|
|||||||
sort.Sort(byHash(tc.effectiveRules))
|
sort.Sort(byHash(tc.effectiveRules))
|
||||||
|
|
||||||
if !reflect.DeepEqual(rules, tc.effectiveRules) {
|
if !reflect.DeepEqual(rules, tc.effectiveRules) {
|
||||||
ruleDiff := diff.ObjectDiff(rules, tc.effectiveRules)
|
ruleDiff := cmp.Diff(rules, tc.effectiveRules)
|
||||||
t.Errorf("case %d: %s", i, ruleDiff)
|
t.Errorf("case %d: %s", i, ruleDiff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -179,6 +179,6 @@ func TestUpdateStatus(t *testing.T) {
|
|||||||
schedulingOut := obj.(*resource.PodSchedulingContext)
|
schedulingOut := obj.(*resource.PodSchedulingContext)
|
||||||
// only compare relevant changes b/c of difference in metadata
|
// only compare relevant changes b/c of difference in metadata
|
||||||
if !apiequality.Semantic.DeepEqual(schedulingCtx.Status, schedulingOut.Status) {
|
if !apiequality.Semantic.DeepEqual(schedulingCtx.Status, schedulingOut.Status) {
|
||||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(schedulingCtx.Status, schedulingOut.Status))
|
t.Errorf("unexpected object: %s", cmp.Diff(schedulingCtx.Status, schedulingOut.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -177,6 +177,6 @@ func TestUpdateStatus(t *testing.T) {
|
|||||||
claimOut := obj.(*resource.ResourceClaim)
|
claimOut := obj.(*resource.ResourceClaim)
|
||||||
// only compare relevant changes b/c of difference in metadata
|
// only compare relevant changes b/c of difference in metadata
|
||||||
if !apiequality.Semantic.DeepEqual(claim.Status, claimOut.Status) {
|
if !apiequality.Semantic.DeepEqual(claim.Status, claimOut.Status) {
|
||||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(claim.Status, claimOut.Status))
|
t.Errorf("unexpected object: %s", cmp.Diff(claim.Status, claimOut.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@ package csistoragecapacity
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/kubernetes/pkg/apis/storage"
|
"k8s.io/kubernetes/pkg/apis/storage"
|
||||||
)
|
)
|
||||||
@ -80,7 +80,7 @@ func TestCSIStorageCapacityStrategy(t *testing.T) {
|
|||||||
|
|
||||||
// Create with status should have kept status and all other fields.
|
// Create with status should have kept status and all other fields.
|
||||||
if !apiequality.Semantic.DeepEqual(capacity, original) {
|
if !apiequality.Semantic.DeepEqual(capacity, original) {
|
||||||
t.Errorf("unexpected objects difference after creation: %v", diff.ObjectDiff(original, capacity))
|
t.Errorf("unexpected objects difference after creation: %v", cmp.Diff(original, capacity))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update of immutable fields is disallowed
|
// Update of immutable fields is disallowed
|
||||||
|
@ -19,12 +19,12 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
@ -194,9 +194,9 @@ func TestEtcdStatusUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
attachmentOut := obj.(*storageapi.VolumeAttachment)
|
attachmentOut := obj.(*storageapi.VolumeAttachment)
|
||||||
if !apiequality.Semantic.DeepEqual(attachmentIn.Spec, attachmentOut.Spec) {
|
if !apiequality.Semantic.DeepEqual(attachmentIn.Spec, attachmentOut.Spec) {
|
||||||
t.Errorf("objects differ: %v", diff.ObjectDiff(attachmentOut.Spec, attachmentIn.Spec))
|
t.Errorf("objects differ: %v", cmp.Diff(attachmentOut.Spec, attachmentIn.Spec))
|
||||||
}
|
}
|
||||||
if !apiequality.Semantic.DeepEqual(attachmentIn.Status, attachmentOut.Status) {
|
if !apiequality.Semantic.DeepEqual(attachmentIn.Status, attachmentOut.Status) {
|
||||||
t.Errorf("objects differ: %v", diff.ObjectDiff(attachmentOut.Status, attachmentIn.Status))
|
t.Errorf("objects differ: %v", cmp.Diff(attachmentOut.Status, attachmentIn.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/storage"
|
"k8s.io/kubernetes/pkg/apis/storage"
|
||||||
@ -90,7 +90,7 @@ func TestVolumeAttachmentStrategy(t *testing.T) {
|
|||||||
statusVolumeAttachment.Status = storage.VolumeAttachmentStatus{Attached: true}
|
statusVolumeAttachment.Status = storage.VolumeAttachmentStatus{Attached: true}
|
||||||
Strategy.PrepareForCreate(ctx, statusVolumeAttachment)
|
Strategy.PrepareForCreate(ctx, statusVolumeAttachment)
|
||||||
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, volumeAttachment) {
|
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, volumeAttachment) {
|
||||||
t.Errorf("unexpected objects difference after creating with status: %v", diff.ObjectDiff(statusVolumeAttachment, volumeAttachment))
|
t.Errorf("unexpected objects difference after creating with status: %v", cmp.Diff(statusVolumeAttachment, volumeAttachment))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update of spec is disallowed
|
// Update of spec is disallowed
|
||||||
@ -111,7 +111,7 @@ func TestVolumeAttachmentStrategy(t *testing.T) {
|
|||||||
Strategy.PrepareForUpdate(ctx, statusVolumeAttachment, volumeAttachment)
|
Strategy.PrepareForUpdate(ctx, statusVolumeAttachment, volumeAttachment)
|
||||||
|
|
||||||
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, volumeAttachment) {
|
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, volumeAttachment) {
|
||||||
t.Errorf("unexpected objects difference after modifying status: %v", diff.ObjectDiff(statusVolumeAttachment, volumeAttachment))
|
t.Errorf("unexpected objects difference after modifying status: %v", cmp.Diff(statusVolumeAttachment, volumeAttachment))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ func TestVolumeAttachmentStrategySourceInlineSpec(t *testing.T) {
|
|||||||
t.Errorf("InlineVolumeSpec unexpectedly set to nil during PrepareForCreate")
|
t.Errorf("InlineVolumeSpec unexpectedly set to nil during PrepareForCreate")
|
||||||
}
|
}
|
||||||
if !apiequality.Semantic.DeepEqual(volumeAttachmentSaved, volumeAttachment) {
|
if !apiequality.Semantic.DeepEqual(volumeAttachmentSaved, volumeAttachment) {
|
||||||
t.Errorf("unexpected difference in object after creation: %v", diff.ObjectDiff(volumeAttachment, volumeAttachmentSaved))
|
t.Errorf("unexpected difference in object after creation: %v", cmp.Diff(volumeAttachment, volumeAttachmentSaved))
|
||||||
}
|
}
|
||||||
Strategy.PrepareForUpdate(ctx, volumeAttachmentSaved, volumeAttachment)
|
Strategy.PrepareForUpdate(ctx, volumeAttachmentSaved, volumeAttachment)
|
||||||
if volumeAttachmentSaved.Spec.Source.InlineVolumeSpec == nil {
|
if volumeAttachmentSaved.Spec.Source.InlineVolumeSpec == nil {
|
||||||
@ -157,7 +157,7 @@ func TestVolumeAttachmentStatusStrategy(t *testing.T) {
|
|||||||
expectedVolumeAttachment := statusVolumeAttachment.DeepCopy()
|
expectedVolumeAttachment := statusVolumeAttachment.DeepCopy()
|
||||||
StatusStrategy.PrepareForUpdate(ctx, statusVolumeAttachment, volumeAttachment)
|
StatusStrategy.PrepareForUpdate(ctx, statusVolumeAttachment, volumeAttachment)
|
||||||
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, expectedVolumeAttachment) {
|
if !apiequality.Semantic.DeepEqual(statusVolumeAttachment, expectedVolumeAttachment) {
|
||||||
t.Errorf("unexpected objects difference after modifying status: %v", diff.ObjectDiff(statusVolumeAttachment, expectedVolumeAttachment))
|
t.Errorf("unexpected objects difference after modifying status: %v", cmp.Diff(statusVolumeAttachment, expectedVolumeAttachment))
|
||||||
}
|
}
|
||||||
|
|
||||||
// spec and metadata modifications should be dropped
|
// spec and metadata modifications should be dropped
|
||||||
@ -175,7 +175,7 @@ func TestVolumeAttachmentStatusStrategy(t *testing.T) {
|
|||||||
|
|
||||||
StatusStrategy.PrepareForUpdate(ctx, newVolumeAttachment, volumeAttachment)
|
StatusStrategy.PrepareForUpdate(ctx, newVolumeAttachment, volumeAttachment)
|
||||||
if !apiequality.Semantic.DeepEqual(newVolumeAttachment, volumeAttachment) {
|
if !apiequality.Semantic.DeepEqual(newVolumeAttachment, volumeAttachment) {
|
||||||
t.Errorf("unexpected objects difference after modifying spec: %v", diff.ObjectDiff(newVolumeAttachment, volumeAttachment))
|
t.Errorf("unexpected objects difference after modifying spec: %v", cmp.Diff(newVolumeAttachment, volumeAttachment))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -22,13 +22,13 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/component-helpers/auth/rbac/validation"
|
"k8s.io/component-helpers/auth/rbac/validation"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
@ -253,7 +253,7 @@ func testObjects(t *testing.T, list *api.List, fixtureFilename string) {
|
|||||||
t.Logf("Could not update data in %s: %v", filename, err)
|
t.Logf("Could not update data in %s: %v", filename, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
t.Logf("Diff between bootstrap data and fixture data in %s:\n-------------\n%s", filename, diff.StringDiff(string(yamlData), string(expectedYAML)))
|
t.Logf("Diff between bootstrap data and fixture data in %s:\n-------------\n%s", filename, cmp.Diff(string(yamlData), string(expectedYAML)))
|
||||||
t.Logf("If the change is expected, re-run with %s=true to update the fixtures", updateEnvVar)
|
t.Logf("If the change is expected, re-run with %s=true to update the fixtures", updateEnvVar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
fuzz "github.com/google/gofuzz"
|
||||||
|
|
||||||
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
|
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
|
||||||
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ func TestStructuralKubeOpenAPIRoundtrip(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(orig, s) {
|
if !reflect.DeepEqual(orig, s) {
|
||||||
t.Fatalf("original and result differ: %v", diff.ObjectGoPrintDiff(orig, s))
|
t.Fatalf("original and result differ: %v", cmp.Diff(orig, s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
apiextensionsinternal "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
|
apiextensionsinternal "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
|
||||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema"
|
structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apiserver/pkg/endpoints"
|
"k8s.io/apiserver/pkg/endpoints"
|
||||||
@ -438,7 +438,7 @@ func TestNewBuilder(t *testing.T) {
|
|||||||
|
|
||||||
gotListSchema := got.listSchema.Properties["items"].Items.Schema
|
gotListSchema := got.listSchema.Properties["items"].Items.Schema
|
||||||
if !reflect.DeepEqual(&wantedItemsSchema, gotListSchema) {
|
if !reflect.DeepEqual(&wantedItemsSchema, gotListSchema) {
|
||||||
t.Errorf("unexpected list schema: %s (want/got)", schemaDiff(&wantedItemsSchema, gotListSchema))
|
t.Errorf("unexpected list schema:\n%s", schemaDiff(&wantedItemsSchema, gotListSchema))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -560,15 +560,8 @@ func properties(p map[string]spec.Schema) sets.String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func schemaDiff(a, b *spec.Schema) string {
|
func schemaDiff(a, b *spec.Schema) string {
|
||||||
as, err := json.Marshal(a)
|
// This option construct allows diffing all fields, even unexported ones.
|
||||||
if err != nil {
|
return cmp.Diff(a, b, cmp.Exporter(func(reflect.Type) bool { return true }))
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
bs, err := json.Marshal(b)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return diff.StringDiff(string(as), string(bs))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildOpenAPIV2(t *testing.T) {
|
func TestBuildOpenAPIV2(t *testing.T) {
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/gofuzz"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
fuzz "github.com/google/gofuzz"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLabelSelectorAsSelector(t *testing.T) {
|
func TestLabelSelectorAsSelector(t *testing.T) {
|
||||||
@ -211,7 +211,7 @@ func TestResetObjectMetaForStatus(t *testing.T) {
|
|||||||
existingMeta.SetManagedFields(nil)
|
existingMeta.SetManagedFields(nil)
|
||||||
|
|
||||||
if !reflect.DeepEqual(meta, existingMeta) {
|
if !reflect.DeepEqual(meta, existingMeta) {
|
||||||
t.Error(diff.ObjectDiff(meta, existingMeta))
|
t.Error(cmp.Diff(meta, existingMeta))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPreferredVersionsAllGroups(t *testing.T) {
|
func TestPreferredVersionsAllGroups(t *testing.T) {
|
||||||
@ -124,7 +124,7 @@ func TestPreferredVersionsAllGroups(t *testing.T) {
|
|||||||
for group, expected := range test.expectedPrioritized {
|
for group, expected := range test.expectedPrioritized {
|
||||||
actual := scheme.PrioritizedVersionsForGroup(group)
|
actual := scheme.PrioritizedVersionsForGroup(group)
|
||||||
if !reflect.DeepEqual(expected, actual) {
|
if !reflect.DeepEqual(expected, actual) {
|
||||||
t.Error(diff.ObjectDiff(expected, actual))
|
t.Error(cmp.Diff(expected, actual))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ func TestPreferredVersionsAllGroups(t *testing.T) {
|
|||||||
actualPrioritizedAll[actual.Group] = append(actualPrioritizedAll[actual.Group], actual)
|
actualPrioritizedAll[actual.Group] = append(actualPrioritizedAll[actual.Group], actual)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(test.expectedPrioritized, actualPrioritizedAll) {
|
if !reflect.DeepEqual(test.expectedPrioritized, actualPrioritizedAll) {
|
||||||
t.Error(diff.ObjectDiff(test.expectedPrioritized, actualPrioritizedAll))
|
t.Error(cmp.Diff(test.expectedPrioritized, actualPrioritizedAll))
|
||||||
}
|
}
|
||||||
|
|
||||||
preferredAll := scheme.PreferredVersionAllGroups()
|
preferredAll := scheme.PreferredVersionAllGroups()
|
||||||
@ -143,7 +143,7 @@ func TestPreferredVersionsAllGroups(t *testing.T) {
|
|||||||
actualPreferredAll[actual] = true
|
actualPreferredAll[actual] = true
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(test.expectedPreferred, actualPreferredAll) {
|
if !reflect.DeepEqual(test.expectedPreferred, actualPreferredAll) {
|
||||||
t.Error(diff.ObjectDiff(test.expectedPreferred, actualPreferredAll))
|
t.Error(cmp.Diff(test.expectedPreferred, actualPreferredAll))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/diff"
|
"k8s.io/apimachinery/pkg/util/diff"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
fuzz "github.com/google/gofuzz"
|
||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
@ -128,7 +129,7 @@ func runTest(t *testing.T, source interface{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !semantic.DeepEqual(source, obj3) {
|
if !semantic.DeepEqual(source, obj3) {
|
||||||
t.Errorf("3: %v: diff: %v", name, diff.ObjectDiff(source, obj3))
|
t.Errorf("3: %v: diff: %v", name, cmp.Diff(source, obj3))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@ package serializer
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type FakeV1Obj struct {
|
type FakeV1Obj struct {
|
||||||
@ -83,9 +83,9 @@ func TestSparse(t *testing.T) {
|
|||||||
uncastDstObj2.(*FakeV2DifferentObj).TypeMeta = metav1.TypeMeta{}
|
uncastDstObj2.(*FakeV2DifferentObj).TypeMeta = metav1.TypeMeta{}
|
||||||
|
|
||||||
if !equality.Semantic.DeepEqual(srcObj1, uncastDstObj1) {
|
if !equality.Semantic.DeepEqual(srcObj1, uncastDstObj1) {
|
||||||
t.Fatal(diff.ObjectDiff(srcObj1, uncastDstObj1))
|
t.Fatal(cmp.Diff(srcObj1, uncastDstObj1))
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(srcObj2, uncastDstObj2) {
|
if !equality.Semantic.DeepEqual(srcObj2, uncastDstObj2) {
|
||||||
t.Fatal(diff.ObjectDiff(srcObj2, uncastDstObj2))
|
t.Fatal(cmp.Diff(srcObj2, uncastDstObj2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
fuzz "github.com/google/gofuzz"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
@ -27,11 +28,10 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/apis/testapigroup"
|
"k8s.io/apimachinery/pkg/apis/testapigroup"
|
||||||
"k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsList(t *testing.T) {
|
func TestIsList(t *testing.T) {
|
||||||
@ -283,7 +283,7 @@ func TestSetListToRuntimeObjectArray(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for i := range list {
|
for i := range list {
|
||||||
if e, a := list[i], pl.Items[i]; e != a {
|
if e, a := list[i], pl.Items[i]; e != a {
|
||||||
t.Fatalf("%d: unmatched: %s", i, diff.ObjectDiff(e, a))
|
t.Fatalf("%d: unmatched: %s", i, cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ func TestSetListToMatchingType(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for i := range list {
|
for i := range list {
|
||||||
if e, a := list[i], &pl.Items[i]; !reflect.DeepEqual(e, a) {
|
if e, a := list[i], &pl.Items[i]; !reflect.DeepEqual(e, a) {
|
||||||
t.Fatalf("%d: unmatched: %s", i, diff.ObjectDiff(e, a))
|
t.Fatalf("%d: unmatched: %s", i, cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
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/apis/testapigroup/v1"
|
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer/protobuf"
|
"k8s.io/apimachinery/pkg/runtime/serializer/protobuf"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type testObject struct {
|
type testObject struct {
|
||||||
@ -355,7 +355,7 @@ func TestDecodeObjects(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !apiequality.Semantic.DeepEqual(obj, test.obj) {
|
if !apiequality.Semantic.DeepEqual(obj, test.obj) {
|
||||||
t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintDiff(test.obj, obj))
|
t.Errorf("%d: unexpected object:\n%s", i, cmp.Diff(test.obj, obj))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,30 +27,16 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/dump"
|
"k8s.io/apimachinery/pkg/util/dump"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StringDiff diffs a and b and returns a human readable diff.
|
|
||||||
func StringDiff(a, b string) string {
|
|
||||||
ba := []byte(a)
|
|
||||||
bb := []byte(b)
|
|
||||||
out := []byte{}
|
|
||||||
i := 0
|
|
||||||
for ; i < len(ba) && i < len(bb); i++ {
|
|
||||||
if ba[i] != bb[i] {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
out = append(out, ba[i])
|
|
||||||
}
|
|
||||||
out = append(out, []byte("\n\nA: ")...)
|
|
||||||
out = append(out, ba[i:]...)
|
|
||||||
out = append(out, []byte("\n\nB: ")...)
|
|
||||||
out = append(out, bb[i:]...)
|
|
||||||
out = append(out, []byte("\n\n")...)
|
|
||||||
return string(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
func legacyDiff(a, b interface{}) string {
|
func legacyDiff(a, b interface{}) string {
|
||||||
return cmp.Diff(a, b)
|
return cmp.Diff(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StringDiff diffs a and b and returns a human readable diff.
|
||||||
|
// DEPRECATED: use github.com/google/go-cmp/cmp.Diff
|
||||||
|
func StringDiff(a, b string) string {
|
||||||
|
return legacyDiff(a, b)
|
||||||
|
}
|
||||||
|
|
||||||
// ObjectDiff prints the diff of two go objects and fails if the objects
|
// ObjectDiff prints the diff of two go objects and fails if the objects
|
||||||
// contain unhandled unexported fields.
|
// contain unhandled unexported fields.
|
||||||
// DEPRECATED: use github.com/google/go-cmp/cmp.Diff
|
// DEPRECATED: use github.com/google/go-cmp/cmp.Diff
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package diff
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestStringDiff(t *testing.T) {
|
|
||||||
diff := StringDiff("aaabb", "aaacc")
|
|
||||||
expect := "aaa\n\nA: bb\n\nB: cc\n\n"
|
|
||||||
if diff != expect {
|
|
||||||
t.Errorf("diff returned %v", diff)
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 {
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -23,12 +23,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apiserver/pkg/apis/audit"
|
"k8s.io/apiserver/pkg/apis/audit"
|
||||||
|
|
||||||
// import to call webhook's init() function to register audit.Policy to schema
|
// import to call webhook's init() function to register audit.Policy to schema
|
||||||
_ "k8s.io/apiserver/plugin/pkg/audit/webhook"
|
_ "k8s.io/apiserver/plugin/pkg/audit/webhook"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@ -113,7 +113,7 @@ func TestParser(t *testing.T) {
|
|||||||
|
|
||||||
assert.Len(t, policy.Rules, 3) // Sanity check.
|
assert.Len(t, policy.Rules, 3) // Sanity check.
|
||||||
if !reflect.DeepEqual(policy, expectedPolicy) {
|
if !reflect.DeepEqual(policy, expectedPolicy) {
|
||||||
t.Errorf("Unexpected policy! Diff:\n%s", diff.ObjectDiff(policy, expectedPolicy))
|
t.Errorf("Unexpected policy! Diff:\n%s", cmp.Diff(policy, expectedPolicy))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
"github.com/google/go-cmp/cmp"
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ func TestAuthenticate(t *testing.T) {
|
|||||||
t.Errorf("Unexpected authentication. got=%v, want=%v", got, want)
|
t.Errorf("Unexpected authentication. got=%v, want=%v", got, want)
|
||||||
}
|
}
|
||||||
if got, want := resp, treq.wantResp; !reflect.DeepEqual(got, want) {
|
if got, want := resp, treq.wantResp; !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf("Unexpected response. diff:\n%v", diff.ObjectGoPrintDiff(got, want))
|
t.Errorf("Unexpected response. diff:\n%v", cmp.Diff(got, want))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful/v3"
|
"github.com/emicklei/go-restful/v3"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
|
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
@ -55,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"
|
||||||
@ -1832,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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -2061,13 +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) {
|
||||||
for i := range test.expected {
|
t.Fatalf("unexpected: %s", cmp.Diff(test.expected, actual))
|
||||||
if i >= len(actual) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
t.Logf("%s", diff.StringDiff(string(test.expected[i].Object.Raw), string(actual[i].Object.Raw)))
|
|
||||||
}
|
|
||||||
t.Fatalf("unexpected: %s", diff.ObjectReflectDiff(test.expected, actual))
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -2245,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 {
|
||||||
@ -2829,7 +2823,7 @@ func TestDeleteWithOptions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
|
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
|
||||||
if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
|
if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
|
||||||
t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item))
|
t.Errorf("unexpected delete options: %s", cmp.Diff(simpleStorage.deleteOptions, item))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2869,7 +2863,7 @@ func TestDeleteWithOptionsQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
|
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
|
||||||
if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
|
if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
|
||||||
t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item))
|
t.Errorf("unexpected delete options: %s", cmp.Diff(simpleStorage.deleteOptions, item))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2912,7 +2906,7 @@ func TestDeleteWithOptionsQueryAndBody(t *testing.T) {
|
|||||||
}
|
}
|
||||||
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
|
simpleStorage.deleteOptions.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
|
||||||
if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
|
if !apiequality.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
|
||||||
t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item))
|
t.Errorf("unexpected delete options: %s", cmp.Diff(simpleStorage.deleteOptions, item))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
jsonpatch "github.com/evanphx/json-patch"
|
jsonpatch "github.com/evanphx/json-patch"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
fuzz "github.com/google/gofuzz"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
@ -38,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"
|
||||||
@ -583,7 +583,7 @@ func (tc *patchTestCase) Run(t *testing.T) {
|
|||||||
reallyExpectedPod := expectedObj.(*example.Pod)
|
reallyExpectedPod := expectedObj.(*example.Pod)
|
||||||
|
|
||||||
if !reflect.DeepEqual(*reallyExpectedPod, *resultPod) {
|
if !reflect.DeepEqual(*reallyExpectedPod, *resultPod) {
|
||||||
t.Errorf("%s mismatch: %v\n", tc.name, diff.ObjectGoPrintDiff(reallyExpectedPod, resultPod))
|
t.Errorf("%s mismatch: %v\n", tc.name, cmp.Diff(reallyExpectedPod, resultPod))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1279,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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"golang.org/x/net/websocket"
|
"golang.org/x/net/websocket"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
@ -41,7 +42,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
|
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
example "k8s.io/apiserver/pkg/apis/example"
|
example "k8s.io/apiserver/pkg/apis/example"
|
||||||
@ -397,7 +397,7 @@ func TestWatchRead(t *testing.T) {
|
|||||||
t.Fatalf("%s: Decode error: %v", name, err)
|
t.Fatalf("%s: Decode error: %v", name, err)
|
||||||
}
|
}
|
||||||
if e, a := object, gotObj; !apiequality.Semantic.DeepEqual(e, a) {
|
if e, a := object, gotObj; !apiequality.Semantic.DeepEqual(e, a) {
|
||||||
t.Errorf("%s: different: %s", name, diff.ObjectDiff(e, a))
|
t.Errorf("%s: different: %s", name, cmp.Diff(e, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.Stop()
|
w.Stop()
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,9 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
authorizationv1 "k8s.io/api/authorization/v1"
|
authorizationv1 "k8s.io/api/authorization/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/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||||
@ -556,7 +556,7 @@ func TestV1Webhook(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(gotAttr, tt.want) {
|
if !reflect.DeepEqual(gotAttr, tt.want) {
|
||||||
t.Errorf("case %d: got != want:\n%s", i, diff.ObjectGoPrintDiff(gotAttr, tt.want))
|
t.Errorf("case %d: got != want:\n%s", i, cmp.Diff(gotAttr, tt.want))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,9 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
authorizationv1beta1 "k8s.io/api/authorization/v1beta1"
|
authorizationv1beta1 "k8s.io/api/authorization/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||||
webhookutil "k8s.io/apiserver/pkg/util/webhook"
|
webhookutil "k8s.io/apiserver/pkg/util/webhook"
|
||||||
@ -548,7 +548,7 @@ func TestV1beta1Webhook(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(gotAttr, tt.want) {
|
if !reflect.DeepEqual(gotAttr, tt.want) {
|
||||||
t.Errorf("case %d: got != want:\n%s", i, diff.ObjectGoPrintDiff(gotAttr, tt.want))
|
t.Errorf("case %d: got != want:\n%s", i, cmp.Diff(gotAttr, tt.want))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ require (
|
|||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
github.com/evanphx/json-patch v4.12.0+incompatible
|
github.com/evanphx/json-patch v4.12.0+incompatible
|
||||||
github.com/google/gnostic v0.5.7-v3refs
|
github.com/google/gnostic v0.5.7-v3refs
|
||||||
|
github.com/google/go-cmp v0.5.9
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
|
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
|
||||||
github.com/spf13/cobra v1.6.0
|
github.com/spf13/cobra v1.6.0
|
||||||
@ -36,7 +37,6 @@ require (
|
|||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/google/btree v1.0.1 // indirect
|
github.com/google/btree v1.0.1 // indirect
|
||||||
github.com/google/go-cmp v0.5.9 // indirect
|
|
||||||
github.com/google/gofuzz v1.1.0 // indirect
|
github.com/google/gofuzz v1.1.0 // indirect
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
|
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
|
||||||
|
@ -21,10 +21,10 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
)
|
)
|
||||||
@ -74,7 +74,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(testData, poutput) {
|
if !reflect.DeepEqual(testData, poutput) {
|
||||||
t.Errorf("Test data and unmarshaled data are not equal: %v", diff.ObjectDiff(poutput, testData))
|
t.Errorf("Test data and unmarshaled data are not equal: %v", cmp.Diff(poutput, testData))
|
||||||
}
|
}
|
||||||
|
|
||||||
obj := &v1.Pod{
|
obj := &v1.Pod{
|
||||||
@ -97,7 +97,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(obj, &objOut) {
|
if !reflect.DeepEqual(obj, &objOut) {
|
||||||
t.Errorf("Unexpected inequality:\n%v", diff.ObjectDiff(obj, &objOut))
|
t.Errorf("Unexpected inequality:\n%v", cmp.Diff(obj, &objOut))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,12 +21,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/client-go/dynamic/dynamicinformer"
|
"k8s.io/client-go/dynamic/dynamicinformer"
|
||||||
"k8s.io/client-go/dynamic/fake"
|
"k8s.io/client-go/dynamic/fake"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
@ -118,7 +118,7 @@ func TestFilteredDynamicSharedInformerFactory(t *testing.T) {
|
|||||||
t.Errorf("informer received an object for namespace %s when watching namespace %s", ts.ns, ts.informNS)
|
t.Errorf("informer received an object for namespace %s when watching namespace %s", ts.ns, ts.informNS)
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(testObject, objFromInformer) {
|
if !equality.Semantic.DeepEqual(testObject, objFromInformer) {
|
||||||
t.Fatalf("%v", diff.ObjectDiff(testObject, objFromInformer))
|
t.Fatalf("%v", cmp.Diff(testObject, objFromInformer))
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
if ts.ns == ts.informNS {
|
if ts.ns == ts.informNS {
|
||||||
@ -239,7 +239,7 @@ func TestDynamicSharedInformerFactory(t *testing.T) {
|
|||||||
select {
|
select {
|
||||||
case objFromInformer := <-informerReciveObjectCh:
|
case objFromInformer := <-informerReciveObjectCh:
|
||||||
if !equality.Semantic.DeepEqual(testObject, objFromInformer) {
|
if !equality.Semantic.DeepEqual(testObject, objFromInformer) {
|
||||||
t.Fatalf("%v", diff.ObjectDiff(testObject, objFromInformer))
|
t.Fatalf("%v", cmp.Diff(testObject, objFromInformer))
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
t.Errorf("tested informer haven't received an object, waited %v", timeout)
|
t.Errorf("tested informer haven't received an object, waited %v", timeout)
|
||||||
|
@ -20,11 +20,11 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
"k8s.io/client-go/dynamic/dynamiclister"
|
"k8s.io/client-go/dynamic/dynamiclister"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
)
|
)
|
||||||
@ -90,7 +90,7 @@ func TestNamespaceGetMethod(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(test.expectedObject, actualObject) {
|
if !reflect.DeepEqual(test.expectedObject, actualObject) {
|
||||||
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, diff.ObjectDiff(test.expectedObject, actualObject))
|
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, cmp.Diff(test.expectedObject, actualObject))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ func TestListerGetMethod(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(test.expectedObject, actualObject) {
|
if !reflect.DeepEqual(test.expectedObject, actualObject) {
|
||||||
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, diff.ObjectDiff(test.expectedObject, actualObject))
|
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", test.expectedObject, actualObject, cmp.Diff(test.expectedObject, actualObject))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ func assertListOrDie(expected, actual []*unstructured.Unstructured, t *testing.T
|
|||||||
for _, actualObject := range actual {
|
for _, actualObject := range actual {
|
||||||
if actualObject.GetName() == expectedObject.GetName() {
|
if actualObject.GetName() == expectedObject.GetName() {
|
||||||
if !reflect.DeepEqual(expectedObject, actualObject) {
|
if !reflect.DeepEqual(expectedObject, actualObject) {
|
||||||
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", expectedObject, actualObject, diff.ObjectDiff(expectedObject, actualObject))
|
t.Fatalf("unexpected object has been returned expected = %v actual = %v, diff = %v", expectedObject, actualObject, cmp.Diff(expectedObject, actualObject))
|
||||||
}
|
}
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,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"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -80,7 +79,7 @@ func TestGet(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(get, expected) {
|
if !equality.Semantic.DeepEqual(get, expected) {
|
||||||
t.Fatal(diff.ObjectGoPrintDiff(expected, get))
|
t.Fatal(cmp.Diff(expected, get))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +98,7 @@ func TestListDecoding(t *testing.T) {
|
|||||||
Items: []unstructured.Unstructured{},
|
Items: []unstructured.Unstructured{},
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(list, expectedList) {
|
if !equality.Semantic.DeepEqual(list, expectedList) {
|
||||||
t.Fatal(diff.ObjectGoPrintDiff(expectedList, list))
|
t.Fatal(cmp.Diff(expectedList, list))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +116,7 @@ func TestGetDecoding(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(get, expectedObj) {
|
if !equality.Semantic.DeepEqual(get, expectedObj) {
|
||||||
t.Fatal(diff.ObjectGoPrintDiff(expectedObj, get))
|
t.Fatal(cmp.Diff(expectedObj, get))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +144,7 @@ func TestList(t *testing.T) {
|
|||||||
*newUnstructured("group/version", "TheKind", "ns-foo", "name-foo"),
|
*newUnstructured("group/version", "TheKind", "ns-foo", "name-foo"),
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(listFirst.Items, expected) {
|
if !equality.Semantic.DeepEqual(listFirst.Items, expected) {
|
||||||
t.Fatal(diff.ObjectGoPrintDiff(expected, listFirst.Items))
|
t.Fatal(cmp.Diff(expected, listFirst.Items))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +188,7 @@ func Test_ListKind(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(listFirst, expectedList) {
|
if !equality.Semantic.DeepEqual(listFirst, expectedList) {
|
||||||
t.Fatal(diff.ObjectGoPrintDiff(expectedList, listFirst))
|
t.Fatal(cmp.Diff(expectedList, listFirst))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +241,7 @@ func (tc *patchTestCase) verifyResult(result *unstructured.Unstructured) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(result, tc.expectedPatchedObject) {
|
if !equality.Semantic.DeepEqual(result, tc.expectedPatchedObject) {
|
||||||
return fmt.Errorf("unexpected diff in received object: %s", diff.ObjectGoPrintDiff(tc.expectedPatchedObject, result))
|
return fmt.Errorf("unexpected diff in received object: %s", cmp.Diff(tc.expectedPatchedObject, result))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -79,7 +79,7 @@ func TestList(t *testing.T) {
|
|||||||
*newPartialObjectMetadata("group/version", "TheKind", "ns-foo", "name-foo"),
|
*newPartialObjectMetadata("group/version", "TheKind", "ns-foo", "name-foo"),
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(listFirst.Items, expected) {
|
if !equality.Semantic.DeepEqual(listFirst.Items, expected) {
|
||||||
t.Fatal(diff.ObjectGoPrintDiff(expected, listFirst.Items))
|
t.Fatal(cmp.Diff(expected, listFirst.Items))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ func (tc *patchTestCase) verifyResult(result *metav1.PartialObjectMetadata) erro
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !equality.Semantic.DeepEqual(result, tc.expectedPatchedObject) {
|
if !equality.Semantic.DeepEqual(result, tc.expectedPatchedObject) {
|
||||||
return fmt.Errorf("unexpected diff in received object: %s", diff.ObjectGoPrintDiff(tc.expectedPatchedObject, result))
|
return fmt.Errorf("unexpected diff in received object: %s", cmp.Diff(tc.expectedPatchedObject, result))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user