Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apiextensions-apiserver: change k8s.io/apimachinery/pkg/util/diff to github.com/google/go-cmp/cmp #112691

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,13 +23,13 @@ import (

"github.com/google/go-cmp/cmp"

v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/validation"

v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
)

func TestRestoreObjectMeta(t *testing.T) {
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestRestoreObjectMeta(t *testing.T) {
}

if !reflect.DeepEqual(tt.converted, tt.expected) {
t.Errorf("unexpected result: %s", diff.ObjectDiff(tt.expected, tt.converted))
t.Errorf("unexpected result: %s", cmp.Diff(tt.expected, tt.converted))
}
})
}
Expand Down
Expand Up @@ -22,11 +22,11 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"
fuzz "github.com/google/gofuzz"

"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json"
)

Expand Down Expand Up @@ -100,7 +100,7 @@ func TestStructuralRoundtripOrError(t *testing.T) {
}

if !reflect.DeepEqual(origSchema, internalSchema) {
t.Fatalf("original and result differ: %v", diff.ObjectDiff(origSchema, internalSchema))
t.Fatalf("original and result differ: %v", cmp.Diff(origSchema, internalSchema))
}
}
}
Expand Up @@ -22,9 +22,11 @@ import (
"strings"
"testing"

structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema"
"k8s.io/apimachinery/pkg/util/diff"
"github.com/google/go-cmp/cmp"

"k8s.io/apimachinery/pkg/util/json"

structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema"
)

func TestCoerce(t *testing.T) {
Expand Down Expand Up @@ -523,7 +525,7 @@ func TestCoerce(t *testing.T) {
if err != nil {
t.Fatalf("unexpected result mashalling error: %v", err)
}
t.Errorf("expected: %s\ngot: %s\ndiff: %s", tt.expected, buf.String(), diff.ObjectDiff(expected, in))
t.Errorf("expected: %s\ngot: %s\ndiff: %s", tt.expected, buf.String(), cmp.Diff(expected, in))
}
if !reflect.DeepEqual(unknownFields, tt.expectedUnknownFields) {
t.Errorf("expected unknown fields:\n\t%v\ngot:\n\t%v\n", strings.Join(tt.expectedUnknownFields, "\n\t"), strings.Join(unknownFields, "\n\t"))
Expand Down
Expand Up @@ -22,10 +22,12 @@ import (
"strings"
"testing"

structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema"
"github.com/google/go-cmp/cmp"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json"

structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema"
)

func TestPrune(t *testing.T) {
Expand Down Expand Up @@ -586,7 +588,7 @@ func TestPrune(t *testing.T) {
if err != nil {
t.Fatalf("unexpected result mashalling error: %v", err)
}
t.Errorf("expected object: %s\ngot: %s\ndiff: %s", tt.expectedObject, buf.String(), diff.ObjectDiff(expectedObject, in))
t.Errorf("expected object: %s\ngot: %s\ndiff: %s", tt.expectedObject, buf.String(), cmp.Diff(expectedObject, in))
}
if !reflect.DeepEqual(pruned, tt.expectedPruned) {
t.Errorf("expected pruned:\n\t%v\ngot:\n\t%v\n", strings.Join(tt.expectedPruned, "\n\t"), strings.Join(pruned, "\n\t"))
Expand All @@ -602,7 +604,7 @@ func TestPrune(t *testing.T) {
if err != nil {
t.Fatalf("unexpected result mashalling error: %v", err)
}
t.Errorf("expected object: %s\ngot: %s\ndiff: %s", tt.expectedObject, buf.String(), diff.ObjectDiff(expectedObject, in))
t.Errorf("expected object: %s\ngot: %s\ndiff: %s", tt.expectedObject, buf.String(), cmp.Diff(expectedObject, in))
}
if len(emptyPruned) > 0 {
t.Errorf("unexpectedly returned pruned fields: %v", emptyPruned)
Expand Down
Expand Up @@ -24,6 +24,8 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"

autoscalingv1 "k8s.io/api/autoscaling/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -32,7 +34,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/generic"
Expand Down Expand Up @@ -408,7 +409,7 @@ func TestScaleGet(t *testing.T) {

got := obj.(*autoscalingv1.Scale)
if !apiequality.Semantic.DeepEqual(got, want) {
t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want))
t.Errorf("unexpected scale: %s", cmp.Diff(got, want))
}
}

Expand Down
Expand Up @@ -24,24 +24,25 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"
"go.etcd.io/etcd/client/pkg/v3/transport"
clientv3 "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc"
"sigs.k8s.io/yaml"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
serveroptions "k8s.io/apiextensions-apiserver/pkg/cmd/server/options"
"k8s.io/apiextensions-apiserver/test/integration/fixtures"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/client-go/dynamic"
"k8s.io/utils/pointer"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
serveroptions "k8s.io/apiextensions-apiserver/pkg/cmd/server/options"
"k8s.io/apiextensions-apiserver/test/integration/fixtures"
)

func TestPostInvalidObjectMeta(t *testing.T) {
Expand Down Expand Up @@ -465,7 +466,7 @@ func TestEmbeddedResources(t *testing.T) {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, foo.Object) {
t.Errorf("unexpected diff: %s", diff.ObjectDiff(expected, foo.Object))
t.Errorf("unexpected diff: %s", cmp.Diff(expected, foo.Object))
}

t.Logf("Trying to create wrongly typed CR")
Expand Down
Expand Up @@ -24,6 +24,8 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"

"go.etcd.io/etcd/client/pkg/v3/transport"
Expand All @@ -37,7 +39,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -603,6 +604,6 @@ embeddedNested:
t.Fatal(err)
}
if !reflect.DeepEqual(expected, x) {
t.Errorf("unexpected diff: %s", diff.ObjectDiff(expected, x))
t.Errorf("unexpected diff: %s", cmp.Diff(expected, x))
}
}