From 8eb60c2474a11383d4bf7ffa9ae8e41536f6a218 Mon Sep 17 00:00:00 2001 From: wojtekt Date: Thu, 2 Apr 2020 21:47:03 +0200 Subject: [PATCH 1/2] Remove k8s.io/apimachinery/pkg/runtime/serializer/testing directory --- hack/.golint_failures | 1 - .../apimachinery/pkg/runtime/serializer/BUILD | 3 +- .../pkg/runtime/serializer/codec_test.go | 70 +++---- .../pkg/runtime/serializer/testing/BUILD | 36 ---- .../pkg/runtime/serializer/testing/doc.go | 19 -- .../pkg/runtime/serializer/testing/types.go | 114 ---------- .../testing/zz_generated.deepcopy.go | 197 ------------------ .../apimachinery/pkg/runtime/testing/BUILD | 2 + .../{serializer => }/testing/conversion.go | 0 9 files changed, 38 insertions(+), 404 deletions(-) delete mode 100644 staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/BUILD delete mode 100644 staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/doc.go delete mode 100644 staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/types.go delete mode 100644 staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/zz_generated.deepcopy.go rename staging/src/k8s.io/apimachinery/pkg/runtime/{serializer => }/testing/conversion.go (100%) diff --git a/hack/.golint_failures b/hack/.golint_failures index 59e2d9d19f3..bc715058612 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -290,7 +290,6 @@ staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json staging/src/k8s.io/apimachinery/pkg/runtime/serializer/protobuf staging/src/k8s.io/apimachinery/pkg/runtime/serializer/recognizer staging/src/k8s.io/apimachinery/pkg/runtime/serializer/streaming -staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing staging/src/k8s.io/apimachinery/pkg/runtime/testing staging/src/k8s.io/apimachinery/pkg/selection staging/src/k8s.io/apimachinery/pkg/test diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/BUILD b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/BUILD index e9554e336c9..1e4c4b8ec29 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/BUILD +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/BUILD @@ -19,7 +19,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime/testing:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library", "//vendor/github.com/google/gofuzz:go_default_library", @@ -61,7 +61,6 @@ filegroup( "//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/protobuf:all-srcs", "//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/recognizer:all-srcs", "//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/streaming:all-srcs", - "//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing:all-srcs", "//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/versioning:all-srcs", "//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/yaml:all-srcs", ], diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/codec_test.go b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/codec_test.go index e8360385f3e..9625739f300 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/codec_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/codec_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/apimachinery/pkg/conversion" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - serializertesting "k8s.io/apimachinery/pkg/runtime/serializer/testing" + runtimetesting "k8s.io/apimachinery/pkg/runtime/testing" "k8s.io/apimachinery/pkg/util/diff" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -61,7 +61,7 @@ func (testMetaFactory) Interpret(data []byte) (*schema.GroupVersionKind, error) // TestObjectFuzzer can randomly populate all the above objects. var TestObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 100).Funcs( - func(j *serializertesting.MyWeirdCustomEmbeddedVersionKindField, c fuzz.Continue) { + func(j *runtimetesting.MyWeirdCustomEmbeddedVersionKindField, c fuzz.Continue) { c.FuzzNoCustom(j) j.APIVersion = "" j.ObjectKind = "" @@ -78,17 +78,17 @@ func GetTestScheme() (*runtime.Scheme, runtime.Codec) { // Ordinarily, we wouldn't add TestType2, but because this is a test and // both types are from the same package, we need to get it into the system // so that converter will match it with ExternalType2. - s.AddKnownTypes(internalGV, &serializertesting.TestType1{}, &serializertesting.TestType2{}, &serializertesting.ExternalInternalSame{}) - s.AddKnownTypes(externalGV, &serializertesting.ExternalInternalSame{}) - s.AddKnownTypeWithName(externalGV.WithKind("TestType1"), &serializertesting.ExternalTestType1{}) - s.AddKnownTypeWithName(externalGV.WithKind("TestType2"), &serializertesting.ExternalTestType2{}) - s.AddKnownTypeWithName(internalGV.WithKind("TestType3"), &serializertesting.TestType1{}) - s.AddKnownTypeWithName(externalGV.WithKind("TestType3"), &serializertesting.ExternalTestType1{}) - s.AddKnownTypeWithName(externalGV2.WithKind("TestType1"), &serializertesting.ExternalTestType1{}) + s.AddKnownTypes(internalGV, &runtimetesting.TestType1{}, &runtimetesting.TestType2{}, &runtimetesting.ExternalInternalSame{}) + s.AddKnownTypes(externalGV, &runtimetesting.ExternalInternalSame{}) + s.AddKnownTypeWithName(externalGV.WithKind("TestType1"), &runtimetesting.ExternalTestType1{}) + s.AddKnownTypeWithName(externalGV.WithKind("TestType2"), &runtimetesting.ExternalTestType2{}) + s.AddKnownTypeWithName(internalGV.WithKind("TestType3"), &runtimetesting.TestType1{}) + s.AddKnownTypeWithName(externalGV.WithKind("TestType3"), &runtimetesting.ExternalTestType1{}) + s.AddKnownTypeWithName(externalGV2.WithKind("TestType1"), &runtimetesting.ExternalTestType1{}) s.AddUnversionedTypes(externalGV, &metav1.Status{}) - utilruntime.Must(serializertesting.RegisterConversions(s)) + utilruntime.Must(runtimetesting.RegisterConversions(s)) cf := newCodecFactory(s, newSerializersForScheme(s, testMetaFactory{}, CodecFactoryOptions{Pretty: true, Strict: true})) codec := cf.LegacyCodec(schema.GroupVersion{Version: "v1"}) @@ -96,7 +96,7 @@ func GetTestScheme() (*runtime.Scheme, runtime.Codec) { } var semantic = conversion.EqualitiesOrDie( - func(a, b serializertesting.MyWeirdCustomEmbeddedVersionKindField) bool { + func(a, b runtimetesting.MyWeirdCustomEmbeddedVersionKindField) bool { a.APIVersion, a.ObjectKind = "", "" b.APIVersion, b.ObjectKind = "", "" return a == b @@ -135,8 +135,8 @@ func runTest(t *testing.T, source interface{}) { func TestTypes(t *testing.T) { table := []interface{}{ - &serializertesting.TestType1{}, - &serializertesting.ExternalInternalSame{}, + &runtimetesting.TestType1{}, + &runtimetesting.ExternalInternalSame{}, } for _, item := range table { // Try a few times, since runTest uses random values. @@ -153,7 +153,7 @@ func TestVersionedEncoding(t *testing.T) { encoder := info.Serializer codec := cf.EncoderForVersion(encoder, schema.GroupVersion{Version: "v2"}) - out, err := runtime.Encode(codec, &serializertesting.TestType1{}) + out, err := runtime.Encode(codec, &runtimetesting.TestType1{}) if err != nil { t.Fatal(err) } @@ -162,14 +162,14 @@ func TestVersionedEncoding(t *testing.T) { } codec = cf.EncoderForVersion(encoder, schema.GroupVersion{Version: "v3"}) - _, err = runtime.Encode(codec, &serializertesting.TestType1{}) + _, err = runtime.Encode(codec, &runtimetesting.TestType1{}) if err == nil { t.Fatal(err) } // unversioned encode with no versions is written directly to wire codec = cf.EncoderForVersion(encoder, runtime.InternalGroupVersioner) - out, err = runtime.Encode(codec, &serializertesting.TestType1{}) + out, err = runtime.Encode(codec, &runtimetesting.TestType1{}) if err != nil { t.Fatal(err) } @@ -185,7 +185,7 @@ func TestMultipleNames(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - internal := obj.(*serializertesting.TestType1) + internal := obj.(*runtimetesting.TestType1) if internal.A != "value" { t.Fatalf("unexpected decoded object: %#v", internal) } @@ -222,16 +222,16 @@ func TestConvertTypesWhenDefaultNamesMatch(t *testing.T) { s := runtime.NewScheme() // create two names internally, with TestType1 being preferred - s.AddKnownTypeWithName(internalGV.WithKind("TestType1"), &serializertesting.TestType1{}) - s.AddKnownTypeWithName(internalGV.WithKind("OtherType1"), &serializertesting.TestType1{}) + s.AddKnownTypeWithName(internalGV.WithKind("TestType1"), &runtimetesting.TestType1{}) + s.AddKnownTypeWithName(internalGV.WithKind("OtherType1"), &runtimetesting.TestType1{}) // create two names externally, with TestType1 being preferred - s.AddKnownTypeWithName(externalGV.WithKind("TestType1"), &serializertesting.ExternalTestType1{}) - s.AddKnownTypeWithName(externalGV.WithKind("OtherType1"), &serializertesting.ExternalTestType1{}) - if err := serializertesting.RegisterConversions(s); err != nil { + s.AddKnownTypeWithName(externalGV.WithKind("TestType1"), &runtimetesting.ExternalTestType1{}) + s.AddKnownTypeWithName(externalGV.WithKind("OtherType1"), &runtimetesting.ExternalTestType1{}) + if err := runtimetesting.RegisterConversions(s); err != nil { t.Fatalf("unexpected error; %v", err) } - ext := &serializertesting.ExternalTestType1{} + ext := &runtimetesting.ExternalTestType1{} ext.APIVersion = "v1" ext.ObjectKind = "OtherType1" ext.A = "test" @@ -239,7 +239,7 @@ func TestConvertTypesWhenDefaultNamesMatch(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - expect := &serializertesting.TestType1{A: "test"} + expect := &runtimetesting.TestType1{A: "test"} codec := newCodecFactory( s, newSerializersForScheme(s, testMetaFactory{}, CodecFactoryOptions{Pretty: true, Strict: true}), @@ -253,7 +253,7 @@ func TestConvertTypesWhenDefaultNamesMatch(t *testing.T) { t.Errorf("unexpected object: %#v", obj) } - into := &serializertesting.TestType1{} + into := &runtimetesting.TestType1{} if err := runtime.DecodeInto(codec, data, into); err != nil { t.Fatalf("unexpected error: %v", err) } @@ -264,13 +264,13 @@ func TestConvertTypesWhenDefaultNamesMatch(t *testing.T) { func TestEncode_Ptr(t *testing.T) { _, codec := GetTestScheme() - tt := &serializertesting.TestType1{A: "I am a pointer object"} + tt := &runtimetesting.TestType1{A: "I am a pointer object"} data, err := runtime.Encode(codec, tt) obj2, err2 := runtime.Decode(codec, data) if err != nil || err2 != nil { t.Fatalf("Failure: '%v' '%v'\n%s", err, err2, data) } - if _, ok := obj2.(*serializertesting.TestType1); !ok { + if _, ok := obj2.(*runtimetesting.TestType1); !ok { t.Fatalf("Got wrong type") } if !semantic.DeepEqual(obj2, tt) { @@ -293,10 +293,10 @@ func TestBadJSONRejection(t *testing.T) { } } badJSONKindMismatch := []byte(`{"myVersionKey":"v1","myKindKey":"ExternalInternalSame"}`) - if err := runtime.DecodeInto(codec, badJSONKindMismatch, &serializertesting.TestType1{}); err == nil { + if err := runtime.DecodeInto(codec, badJSONKindMismatch, &runtimetesting.TestType1{}); err == nil { t.Errorf("Kind is set but doesn't match the object type: %s", badJSONKindMismatch) } - if err := runtime.DecodeInto(codec, []byte(``), &serializertesting.TestType1{}); err != nil { + if err := runtime.DecodeInto(codec, []byte(``), &runtimetesting.TestType1{}); err != nil { t.Errorf("Should allow empty decode: %v", err) } if _, _, err := codec.Decode([]byte(``), &schema.GroupVersionKind{Kind: "ExternalInternalSame"}, nil); err == nil { @@ -325,12 +325,12 @@ func GetDirectCodecTestScheme() *runtime.Scheme { // Ordinarily, we wouldn't add TestType2, but because this is a test and // both types are from the same package, we need to get it into the system // so that converter will match it with ExternalType2. - s.AddKnownTypes(internalGV, &serializertesting.TestType1{}) - s.AddKnownTypes(externalGV, &serializertesting.ExternalTestType1{}) + s.AddKnownTypes(internalGV, &runtimetesting.TestType1{}) + s.AddKnownTypes(externalGV, &runtimetesting.ExternalTestType1{}) s.AddUnversionedTypes(externalGV, &metav1.Status{}) - utilruntime.Must(serializertesting.RegisterConversions(s)) + utilruntime.Must(runtimetesting.RegisterConversions(s)) return s } @@ -346,7 +346,7 @@ func TestDirectCodec(t *testing.T) { } directEncoder := df.EncoderForVersion(serializer, ignoredGV) directDecoder := df.DecoderToVersion(serializer, ignoredGV) - out, err := runtime.Encode(directEncoder, &serializertesting.ExternalTestType1{}) + out, err := runtime.Encode(directEncoder, &runtimetesting.ExternalTestType1{}) if err != nil { t.Fatal(err) } @@ -357,8 +357,8 @@ func TestDirectCodec(t *testing.T) { if err != nil { t.Fatalf("error on Decode: %v", err) } - e := &serializertesting.ExternalTestType1{ - MyWeirdCustomEmbeddedVersionKindField: serializertesting.MyWeirdCustomEmbeddedVersionKindField{ + e := &runtimetesting.ExternalTestType1{ + MyWeirdCustomEmbeddedVersionKindField: runtimetesting.MyWeirdCustomEmbeddedVersionKindField{ APIVersion: "v1", ObjectKind: "ExternalTestType1", }, diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/BUILD b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/BUILD deleted file mode 100644 index 297ee51a817..00000000000 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/BUILD +++ /dev/null @@ -1,36 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", -) - -go_library( - name = "go_default_library", - srcs = [ - "conversion.go", - "doc.go", - "types.go", - "zz_generated.deepcopy.go", - ], - importmap = "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime/serializer/testing", - importpath = "k8s.io/apimachinery/pkg/runtime/serializer/testing", - deps = [ - "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", - ], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], -) diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/doc.go b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/doc.go deleted file mode 100644 index 6f8d6c55e50..00000000000 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +k8s:deepcopy-gen=package - -package testing // import "k8s.io/apimachinery/pkg/runtime/serializer/testing" diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/types.go b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/types.go deleted file mode 100644 index 7693d75a65f..00000000000 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/types.go +++ /dev/null @@ -1,114 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package testing - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// Test a weird version/kind embedding format. -// +k8s:deepcopy-gen=false -type MyWeirdCustomEmbeddedVersionKindField struct { - ID string `json:"ID,omitempty"` - APIVersion string `json:"myVersionKey,omitempty"` - ObjectKind string `json:"myKindKey,omitempty"` - Z string `json:"Z,omitempty"` - Y uint64 `json:"Y,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type TestType1 struct { - MyWeirdCustomEmbeddedVersionKindField `json:",inline"` - A string `json:"A,omitempty"` - B int `json:"B,omitempty"` - C int8 `json:"C,omitempty"` - D int16 `json:"D,omitempty"` - E int32 `json:"E,omitempty"` - F int64 `json:"F,omitempty"` - G uint `json:"G,omitempty"` - H uint8 `json:"H,omitempty"` - I uint16 `json:"I,omitempty"` - J uint32 `json:"J,omitempty"` - K uint64 `json:"K,omitempty"` - L bool `json:"L,omitempty"` - M map[string]int `json:"M,omitempty"` - N map[string]TestType2 `json:"N,omitempty"` - O *TestType2 `json:"O,omitempty"` - P []TestType2 `json:"Q,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type TestType2 struct { - A string `json:"A,omitempty"` - B int `json:"B,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type ExternalTestType2 struct { - A string `json:"A,omitempty"` - B int `json:"B,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type ExternalTestType1 struct { - MyWeirdCustomEmbeddedVersionKindField `json:",inline"` - A string `json:"A,omitempty"` - B int `json:"B,omitempty"` - C int8 `json:"C,omitempty"` - D int16 `json:"D,omitempty"` - E int32 `json:"E,omitempty"` - F int64 `json:"F,omitempty"` - G uint `json:"G,omitempty"` - H uint8 `json:"H,omitempty"` - I uint16 `json:"I,omitempty"` - J uint32 `json:"J,omitempty"` - K uint64 `json:"K,omitempty"` - L bool `json:"L,omitempty"` - M map[string]int `json:"M,omitempty"` - N map[string]ExternalTestType2 `json:"N,omitempty"` - O *ExternalTestType2 `json:"O,omitempty"` - P []ExternalTestType2 `json:"Q,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type ExternalInternalSame struct { - MyWeirdCustomEmbeddedVersionKindField `json:",inline"` - A TestType2 `json:"A,omitempty"` -} - -func (obj *MyWeirdCustomEmbeddedVersionKindField) GetObjectKind() schema.ObjectKind { return obj } -func (obj *MyWeirdCustomEmbeddedVersionKindField) SetGroupVersionKind(gvk schema.GroupVersionKind) { - obj.APIVersion, obj.ObjectKind = gvk.ToAPIVersionAndKind() -} -func (obj *MyWeirdCustomEmbeddedVersionKindField) GroupVersionKind() schema.GroupVersionKind { - return schema.FromAPIVersionAndKind(obj.APIVersion, obj.ObjectKind) -} - -func (obj *ExternalInternalSame) GetObjectKind() schema.ObjectKind { - return &obj.MyWeirdCustomEmbeddedVersionKindField -} - -func (obj *TestType1) GetObjectKind() schema.ObjectKind { - return &obj.MyWeirdCustomEmbeddedVersionKindField -} - -func (obj *ExternalTestType1) GetObjectKind() schema.ObjectKind { - return &obj.MyWeirdCustomEmbeddedVersionKindField -} - -func (obj *TestType2) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind } -func (obj *ExternalTestType2) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind } diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/zz_generated.deepcopy.go b/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/zz_generated.deepcopy.go deleted file mode 100644 index b419c0ad9ff..00000000000 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/zz_generated.deepcopy.go +++ /dev/null @@ -1,197 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright 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. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package testing - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExternalInternalSame) DeepCopyInto(out *ExternalInternalSame) { - *out = *in - out.MyWeirdCustomEmbeddedVersionKindField = in.MyWeirdCustomEmbeddedVersionKindField - out.A = in.A - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalInternalSame. -func (in *ExternalInternalSame) DeepCopy() *ExternalInternalSame { - if in == nil { - return nil - } - out := new(ExternalInternalSame) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ExternalInternalSame) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExternalTestType1) DeepCopyInto(out *ExternalTestType1) { - *out = *in - out.MyWeirdCustomEmbeddedVersionKindField = in.MyWeirdCustomEmbeddedVersionKindField - if in.M != nil { - in, out := &in.M, &out.M - *out = make(map[string]int, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.N != nil { - in, out := &in.N, &out.N - *out = make(map[string]ExternalTestType2, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.O != nil { - in, out := &in.O, &out.O - *out = new(ExternalTestType2) - **out = **in - } - if in.P != nil { - in, out := &in.P, &out.P - *out = make([]ExternalTestType2, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalTestType1. -func (in *ExternalTestType1) DeepCopy() *ExternalTestType1 { - if in == nil { - return nil - } - out := new(ExternalTestType1) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ExternalTestType1) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExternalTestType2) DeepCopyInto(out *ExternalTestType2) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalTestType2. -func (in *ExternalTestType2) DeepCopy() *ExternalTestType2 { - if in == nil { - return nil - } - out := new(ExternalTestType2) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ExternalTestType2) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TestType1) DeepCopyInto(out *TestType1) { - *out = *in - out.MyWeirdCustomEmbeddedVersionKindField = in.MyWeirdCustomEmbeddedVersionKindField - if in.M != nil { - in, out := &in.M, &out.M - *out = make(map[string]int, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.N != nil { - in, out := &in.N, &out.N - *out = make(map[string]TestType2, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.O != nil { - in, out := &in.O, &out.O - *out = new(TestType2) - **out = **in - } - if in.P != nil { - in, out := &in.P, &out.P - *out = make([]TestType2, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType1. -func (in *TestType1) DeepCopy() *TestType1 { - if in == nil { - return nil - } - out := new(TestType1) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TestType1) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TestType2) DeepCopyInto(out *TestType2) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType2. -func (in *TestType2) DeepCopy() *TestType2 { - if in == nil { - return nil - } - out := new(TestType2) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TestType2) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/testing/BUILD b/staging/src/k8s.io/apimachinery/pkg/runtime/testing/BUILD index 00f993a892e..c2f6ca6fa96 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/testing/BUILD +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/testing/BUILD @@ -9,6 +9,7 @@ go_library( name = "go_default_library", srcs = [ "cacheable_object.go", + "conversion.go", "doc.go", "types.go", "zz_generated.deepcopy.go", @@ -16,6 +17,7 @@ go_library( importmap = "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime/testing", importpath = "k8s.io/apimachinery/pkg/runtime/testing", deps = [ + "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/json:go_default_library", diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/conversion.go b/staging/src/k8s.io/apimachinery/pkg/runtime/testing/conversion.go similarity index 100% rename from staging/src/k8s.io/apimachinery/pkg/runtime/serializer/testing/conversion.go rename to staging/src/k8s.io/apimachinery/pkg/runtime/testing/conversion.go From 3fb80a6d8201b1b6340bb179ffcc6cc1269cf71c Mon Sep 17 00:00:00 2001 From: wojtekt Date: Thu, 2 Apr 2020 22:04:27 +0200 Subject: [PATCH 2/2] Fix default conversion for pkg/runtime tests --- .../apimachinery/pkg/runtime/embedded_test.go | 5 + .../apimachinery/pkg/runtime/scheme_test.go | 39 ++--- .../pkg/runtime/testing/conversion.go | 152 +++++++++++++++++- 3 files changed, 170 insertions(+), 26 deletions(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/embedded_test.go b/staging/src/k8s.io/apimachinery/pkg/runtime/embedded_test.go index 606e0e96ad6..ded65847300 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/embedded_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/embedded_test.go @@ -27,6 +27,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/serializer" runtimetesting "k8s.io/apimachinery/pkg/runtime/testing" "k8s.io/apimachinery/pkg/util/diff" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" ) func TestDecodeEmptyRawExtensionAsObject(t *testing.T) { @@ -37,6 +38,7 @@ func TestDecodeEmptyRawExtensionAsObject(t *testing.T) { s := runtime.NewScheme() s.AddKnownTypes(internalGV, &runtimetesting.ObjectTest{}) s.AddKnownTypeWithName(externalGVK, &runtimetesting.ObjectTestExternal{}) + utilruntime.Must(runtimetesting.RegisterConversions(s)) codec := serializer.NewCodecFactory(s).LegacyCodec(externalGV) @@ -74,6 +76,7 @@ func TestArrayOfRuntimeObject(t *testing.T) { s.AddKnownTypeWithName(externalGV.WithKind("EmbeddedTest"), &runtimetesting.EmbeddedTestExternal{}) s.AddKnownTypes(internalGV, &runtimetesting.ObjectTest{}) s.AddKnownTypeWithName(externalGV.WithKind("ObjectTest"), &runtimetesting.ObjectTestExternal{}) + utilruntime.Must(runtimetesting.RegisterConversions(s)) codec := serializer.NewCodecFactory(s).LegacyCodec(externalGV) @@ -148,6 +151,7 @@ func TestNestedObject(t *testing.T) { s := runtime.NewScheme() s.AddKnownTypes(internalGV, &runtimetesting.EmbeddedTest{}) s.AddKnownTypeWithName(embeddedTestExternalGVK, &runtimetesting.EmbeddedTestExternal{}) + utilruntime.Must(runtimetesting.RegisterConversions(s)) codec := serializer.NewCodecFactory(s).LegacyCodec(externalGV) @@ -227,6 +231,7 @@ func TestDeepCopyOfRuntimeObject(t *testing.T) { s := runtime.NewScheme() s.AddKnownTypes(internalGV, &runtimetesting.EmbeddedTest{}) s.AddKnownTypeWithName(embeddedTestExternalGVK, &runtimetesting.EmbeddedTestExternal{}) + utilruntime.Must(runtimetesting.RegisterConversions(s)) original := &runtimetesting.EmbeddedTest{ ID: "outer", diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/scheme_test.go b/staging/src/k8s.io/apimachinery/pkg/runtime/scheme_test.go index 260d211f498..0c04eaafae7 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/scheme_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/scheme_test.go @@ -37,23 +37,15 @@ type testConversions struct { } func (c *testConversions) internalToExternalSimple(in *runtimetesting.InternalSimple, out *runtimetesting.ExternalSimple, scope conversion.Scope) error { - if err := scope.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil { - return err - } - if err := scope.Convert(&in.TestString, &out.TestString, 0); err != nil { - return err - } + out.TypeMeta = in.TypeMeta + out.TestString = in.TestString c.internalToExternalCalls++ return nil } func (c *testConversions) externalToInternalSimple(in *runtimetesting.ExternalSimple, out *runtimetesting.InternalSimple, scope conversion.Scope) error { - if err := scope.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil { - return err - } - if err := scope.Convert(&in.TestString, &out.TestString, 0); err != nil { - return err - } + out.TypeMeta = in.TypeMeta + out.TestString = in.TestString c.externalToInternalCalls++ return nil } @@ -81,6 +73,7 @@ func TestScheme(t *testing.T) { scheme := runtime.NewScheme() scheme.AddKnownTypeWithName(internalGVK, &runtimetesting.InternalSimple{}) scheme.AddKnownTypeWithName(externalGVK, &runtimetesting.ExternalSimple{}) + utilruntime.Must(runtimetesting.RegisterConversions(scheme)) // If set, would clear TypeMeta during conversion. //scheme.AddIgnoredConversionType(&TypeMeta{}, &TypeMeta{}) @@ -94,9 +87,7 @@ func TestScheme(t *testing.T) { } // Register functions to verify that scope.Meta() gets set correctly. - if err := conversions.registerConversions(scheme); err != nil { - t.Fatalf("unexpected error: %v", err) - } + utilruntime.Must(conversions.registerConversions(scheme)) t.Run("Encode, Decode, DecodeInto, and DecodeToVersion", func(t *testing.T) { simple := &runtimetesting.InternalSimple{ @@ -272,6 +263,7 @@ func TestExternalToInternalMapping(t *testing.T) { scheme := runtime.NewScheme() scheme.AddKnownTypeWithName(internalGV.WithKind("OptionalExtensionType"), &runtimetesting.InternalOptionalExtensionType{}) scheme.AddKnownTypeWithName(externalGV.WithKind("OptionalExtensionType"), &runtimetesting.ExternalOptionalExtensionType{}) + utilruntime.Must(runtimetesting.RegisterConversions(scheme)) codec := serializer.NewCodecFactory(scheme).LegacyCodec(externalGV) @@ -311,6 +303,7 @@ func TestExtensionMapping(t *testing.T) { scheme.AddKnownTypeWithName(externalGV.WithKind("B"), &runtimetesting.ExtensionB{}) scheme.AddKnownTypeWithName(internalGV.WithKind("A"), &runtimetesting.ExtensionA{}) scheme.AddKnownTypeWithName(internalGV.WithKind("B"), &runtimetesting.ExtensionB{}) + utilruntime.Must(runtimetesting.RegisterConversions(scheme)) codec := serializer.NewCodecFactory(scheme).LegacyCodec(externalGV) @@ -379,6 +372,7 @@ func TestEncode(t *testing.T) { scheme := runtime.NewScheme() scheme.AddKnownTypeWithName(internalGVK, &runtimetesting.InternalSimple{}) scheme.AddKnownTypeWithName(externalGVK, &runtimetesting.ExternalSimple{}) + utilruntime.Must(runtimetesting.RegisterConversions(scheme)) codec := serializer.NewCodecFactory(scheme).LegacyCodec(externalGV) @@ -414,6 +408,7 @@ func TestUnversionedTypes(t *testing.T) { scheme.AddKnownTypeWithName(internalGVK, &runtimetesting.InternalSimple{}) scheme.AddKnownTypeWithName(externalGVK, &runtimetesting.ExternalSimple{}) scheme.AddKnownTypeWithName(otherGV.WithKind("Simple"), &runtimetesting.ExternalSimple{}) + utilruntime.Must(runtimetesting.RegisterConversions(scheme)) codec := serializer.NewCodecFactory(scheme).LegacyCodec(externalGV) @@ -488,14 +483,8 @@ func GetTestScheme() *runtime.Scheme { s.AddKnownTypeWithName(alternateExternalGV.WithKind("TestType5"), &runtimetesting.ExternalTestType1{}) s.AddKnownTypeWithName(differentExternalGV.WithKind("TestType1"), &runtimetesting.ExternalTestType1{}) s.AddUnversionedTypes(externalGV, &runtimetesting.UnversionedType{}) + utilruntime.Must(runtimetesting.RegisterConversions(s)) - convertTestType := func(in *runtimetesting.TestType1, out *runtimetesting.ExternalTestType1, s conversion.Scope) error { - out.A = in.A - return nil - } - utilruntime.Must(s.AddConversionFunc((*runtimetesting.TestType1)(nil), (*runtimetesting.ExternalTestType1)(nil), func(a, b interface{}, scope conversion.Scope) error { - return convertTestType(a.(*runtimetesting.TestType1), b.(*runtimetesting.ExternalTestType1), scope) - })) return s } @@ -941,6 +930,7 @@ func TestMetaValues(t *testing.T) { s := runtime.NewScheme() s.AddKnownTypeWithName(internalGV.WithKind("Simple"), &runtimetesting.InternalSimple{}) s.AddKnownTypeWithName(externalGV.WithKind("Simple"), &runtimetesting.ExternalSimple{}) + utilruntime.Must(runtimetesting.RegisterConversions(s)) conversions := &testConversions{ internalToExternalCalls: 0, @@ -948,9 +938,8 @@ func TestMetaValues(t *testing.T) { } // Register functions to verify that scope.Meta() gets set correctly. - if err := conversions.registerConversions(s); err != nil { - t.Fatalf("unexpected error: %v", err) - } + utilruntime.Must(conversions.registerConversions(s)) + simple := &runtimetesting.InternalSimple{ TestString: "foo", } diff --git a/staging/src/k8s.io/apimachinery/pkg/runtime/testing/conversion.go b/staging/src/k8s.io/apimachinery/pkg/runtime/testing/conversion.go index d1f8eceae3f..384929b17c6 100644 --- a/staging/src/k8s.io/apimachinery/pkg/runtime/testing/conversion.go +++ b/staging/src/k8s.io/apimachinery/pkg/runtime/testing/conversion.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2020 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. @@ -21,6 +21,106 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) +func convertEmbeddedTestToEmbeddedTestExternal(in *EmbeddedTest, out *EmbeddedTestExternal, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + out.ID = in.ID + if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.Object, &out.Object, s); err != nil { + return err + } + if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.EmptyObject, &out.EmptyObject, s); err != nil { + return err + } + return nil +} + +func convertEmbeddedTestExternalToEmbeddedTest(in *EmbeddedTestExternal, out *EmbeddedTest, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + out.ID = in.ID + if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.Object, &out.Object, s); err != nil { + return err + } + if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.EmptyObject, &out.EmptyObject, s); err != nil { + return err + } + return nil +} + +func convertObjectTestToObjectTestExternal(in *ObjectTest, out *ObjectTestExternal, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + out.ID = in.ID + if in.Items != nil { + out.Items = make([]runtime.RawExtension, len(in.Items)) + for i := range in.Items { + if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.Items[i], &out.Items[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +func convertObjectTestExternalToObjectTest(in *ObjectTestExternal, out *ObjectTest, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + out.ID = in.ID + if in.Items != nil { + out.Items = make([]runtime.Object, len(in.Items)) + for i := range in.Items { + if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.Items[i], &out.Items[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +func convertInternalSimpleToExternalSimple(in *InternalSimple, out *ExternalSimple, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + out.TestString = in.TestString + return nil +} + +func convertExternalSimpleToInternalSimple(in *ExternalSimple, out *InternalSimple, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + out.TestString = in.TestString + return nil +} + +func convertInternalExtensionTypeToExternalExtensionType(in *InternalExtensionType, out *ExternalExtensionType, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.Extension, &out.Extension, s); err != nil { + return err + } + return nil +} + +func convertExternalExtensionTypeToInternalExtensionType(in *ExternalExtensionType, out *InternalExtensionType, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.Extension, &out.Extension, s); err != nil { + return err + } + return nil +} + +func convertInternalOptionalExtensionTypeToExternalOptionalExtensionType(in *InternalOptionalExtensionType, out *ExternalOptionalExtensionType, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.Extension, &out.Extension, s); err != nil { + return err + } + return nil +} + +func convertExternalOptionalExtensionTypeToInternalOptionalExtensionType(in *ExternalOptionalExtensionType, out *InternalOptionalExtensionType, s conversion.Scope) error { + out.TypeMeta = in.TypeMeta + if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.Extension, &out.Extension, s); err != nil { + return err + } + return nil +} + func convertTestType1ToExternalTestType1(in *TestType1, out *ExternalTestType1, s conversion.Scope) error { out.MyWeirdCustomEmbeddedVersionKindField = in.MyWeirdCustomEmbeddedVersionKindField out.A = in.A @@ -126,6 +226,56 @@ func convertExternalTestType2ToTestType2(in *ExternalTestType2, out *TestType2, } func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddConversionFunc((*EmbeddedTest)(nil), (*EmbeddedTestExternal)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertEmbeddedTestToEmbeddedTestExternal(a.(*EmbeddedTest), b.(*EmbeddedTestExternal), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*EmbeddedTestExternal)(nil), (*EmbeddedTest)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertEmbeddedTestExternalToEmbeddedTest(a.(*EmbeddedTestExternal), b.(*EmbeddedTest), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ObjectTest)(nil), (*ObjectTestExternal)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertObjectTestToObjectTestExternal(a.(*ObjectTest), b.(*ObjectTestExternal), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ObjectTestExternal)(nil), (*ObjectTest)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertObjectTestExternalToObjectTest(a.(*ObjectTestExternal), b.(*ObjectTest), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*InternalSimple)(nil), (*ExternalSimple)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertInternalSimpleToExternalSimple(a.(*InternalSimple), b.(*ExternalSimple), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ExternalSimple)(nil), (*InternalSimple)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertExternalSimpleToInternalSimple(a.(*ExternalSimple), b.(*InternalSimple), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*InternalExtensionType)(nil), (*ExternalExtensionType)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertInternalExtensionTypeToExternalExtensionType(a.(*InternalExtensionType), b.(*ExternalExtensionType), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ExternalExtensionType)(nil), (*InternalExtensionType)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertExternalExtensionTypeToInternalExtensionType(a.(*ExternalExtensionType), b.(*InternalExtensionType), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*InternalOptionalExtensionType)(nil), (*ExternalOptionalExtensionType)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertInternalOptionalExtensionTypeToExternalOptionalExtensionType(a.(*InternalOptionalExtensionType), b.(*ExternalOptionalExtensionType), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ExternalOptionalExtensionType)(nil), (*InternalOptionalExtensionType)(nil), func(a, b interface{}, scope conversion.Scope) error { + return convertExternalOptionalExtensionTypeToInternalOptionalExtensionType(a.(*ExternalOptionalExtensionType), b.(*InternalOptionalExtensionType), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*TestType1)(nil), (*ExternalTestType1)(nil), func(a, b interface{}, scope conversion.Scope) error { return convertTestType1ToExternalTestType1(a.(*TestType1), b.(*ExternalTestType1), scope) }); err != nil {