mirror of https://github.com/k3s-io/k3s
Merge pull request #48608 from sttts/sttts-typemeta-getobjectkind
Automatic merge from submit-queue (batch tested with PRs 47040, 48597, 48608, 48653) apimachinery: remove unneeded GetObjectKind() impls Based on https://github.com/kubernetes/kubernetes/pull/48601pull/6/head
commit
8c07c9aa8b
|
@ -38,6 +38,3 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
|||
scheme.AddKnownTypes(SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (obj *TestType) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *TestTypeList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
|
|
@ -52,6 +52,3 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
|||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (obj *TestType) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *TestTypeList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
|
|
@ -35,8 +35,6 @@ type ExtensionAPIObject struct {
|
|||
metav1.ObjectMeta
|
||||
}
|
||||
|
||||
func (obj *ExtensionAPIObject) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
func TestGetReference(t *testing.T) {
|
||||
|
||||
// when vendoring kube, if you don't force the set of registered versions (like make test does)
|
||||
|
|
|
@ -60,5 +60,3 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
|||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (obj *Policy) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
|
|
@ -60,5 +60,3 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
|||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (obj *Policy) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
|
|
@ -27,9 +27,6 @@ import (
|
|||
"k8s.io/kubernetes/pkg/api"
|
||||
)
|
||||
|
||||
func (obj *MetadataOnlyObject) GetObjectKind() schema.ObjectKind { return obj }
|
||||
func (obj *MetadataOnlyObjectList) GetObjectKind() schema.ObjectKind { return obj }
|
||||
|
||||
type metaOnlyJSONScheme struct{}
|
||||
|
||||
// This function can be extended to mapping different gvk to different MetadataOnlyObject,
|
||||
|
|
|
@ -18,7 +18,6 @@ go_library(
|
|||
deps = [
|
||||
"//vendor/github.com/ugorji/go/codec:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -18,7 +18,6 @@ package testing
|
|||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
type TestStruct struct {
|
||||
|
@ -30,5 +29,3 @@ type TestStruct struct {
|
|||
StringList []string `json:"StringList"`
|
||||
IntList []int `json:"IntList"`
|
||||
}
|
||||
|
||||
func (obj *TestStruct) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
|
|
@ -28,7 +28,7 @@ func (obj *TypeMeta) GroupVersionKind() schema.GroupVersionKind {
|
|||
return schema.FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
|
||||
}
|
||||
|
||||
func (obj *Unknown) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *TypeMeta) GetObjectKind() schema.ObjectKind { return obj }
|
||||
|
||||
// GetObjectKind implements Object for VersionedObjects, returning an empty ObjectKind
|
||||
// interface if no objects are provided, or the ObjectKind interface of the object in the
|
||||
|
|
|
@ -441,15 +441,10 @@ func TestAddKnownTypesIdemPotent(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// EmbeddableTypeMeta passes GetObjectKind to the type which embeds it.
|
||||
type EmbeddableTypeMeta runtime.TypeMeta
|
||||
|
||||
func (tm *EmbeddableTypeMeta) GetObjectKind() schema.ObjectKind { return (*runtime.TypeMeta)(tm) }
|
||||
|
||||
// redefine InternalSimple with the same name, but obviously as a different type than in runtimetesting
|
||||
type InternalSimple struct {
|
||||
EmbeddableTypeMeta `json:",inline"`
|
||||
TestString string `json:"testString"`
|
||||
runtime.TypeMeta `json:",inline"`
|
||||
TestString string `json:"testString"`
|
||||
}
|
||||
|
||||
func (s *InternalSimple) DeepCopyObject() runtime.Object { return nil }
|
||||
|
|
|
@ -190,23 +190,5 @@ func (obj *MyWeirdCustomEmbeddedVersionKindField) GroupVersionKind() schema.Grou
|
|||
return schema.FromAPIVersionAndKind(obj.APIVersion, obj.ObjectKind)
|
||||
}
|
||||
|
||||
func (obj *TestType2) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
|
||||
func (obj *ExternalTestType2) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
|
||||
func (obj *InternalComplex) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExternalComplex) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *EmbeddedTest) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *EmbeddedTestExternal) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *InternalSimple) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExternalSimple) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *InternalOptionalExtensionType) GetObjectKind() schema.ObjectKind {
|
||||
return &obj.TypeMeta
|
||||
}
|
||||
func (obj *ObjectTestExternal) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ObjectTest) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExternalOptionalExtensionType) GetObjectKind() schema.ObjectKind {
|
||||
return &obj.TypeMeta
|
||||
}
|
||||
func (obj *InternalExtensionType) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExternalExtensionType) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExtensionA) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExtensionB) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *TestType2) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
|
||||
func (obj *ExternalTestType2) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
|
||||
|
|
|
@ -64,8 +64,6 @@ type TestPatchSubType struct {
|
|||
StringField string `json:"theField"`
|
||||
}
|
||||
|
||||
func (obj *testPatchType) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
func TestPatchAnonymousField(t *testing.T) {
|
||||
testGV := schema.GroupVersion{Group: "", Version: "v"}
|
||||
scheme.AddKnownTypes(testGV, &testPatchType{})
|
||||
|
|
|
@ -20,7 +20,6 @@ go_library(
|
|||
"//vendor/github.com/ugorji/go/codec:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -18,7 +18,6 @@ package testing
|
|||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
type Simple struct {
|
||||
|
@ -30,8 +29,6 @@ type Simple struct {
|
|||
Labels map[string]string `json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
func (obj *Simple) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
type SimpleRoot struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata"`
|
||||
|
@ -41,8 +38,6 @@ type SimpleRoot struct {
|
|||
Labels map[string]string `json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
func (obj *SimpleRoot) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
type SimpleGetOptions struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
Param1 string `json:"param1"`
|
||||
|
@ -57,8 +52,6 @@ func (SimpleGetOptions) SwaggerDoc() map[string]string {
|
|||
}
|
||||
}
|
||||
|
||||
func (obj *SimpleGetOptions) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
type SimpleList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,inline"`
|
||||
|
@ -66,8 +59,6 @@ type SimpleList struct {
|
|||
Items []Simple `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
func (obj *SimpleList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
// SimpleXGSubresource is a cross group subresource, i.e. the subresource does not belong to the
|
||||
// same group as its parent resource.
|
||||
type SimpleXGSubresource struct {
|
||||
|
@ -76,5 +67,3 @@ type SimpleXGSubresource struct {
|
|||
SubresourceInfo string `json:"subresourceInfo,omitempty"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
func (obj *SimpleXGSubresource) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
|
|
@ -24,7 +24,6 @@ go_library(
|
|||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
|
||||
],
|
||||
|
|
|
@ -18,7 +18,6 @@ package testing
|
|||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
type TestResource struct {
|
||||
|
@ -26,5 +25,3 @@ type TestResource struct {
|
|||
metav1.ObjectMeta `json:"metadata"`
|
||||
Value int `json:"value"`
|
||||
}
|
||||
|
||||
func (obj *TestResource) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
|
||||
|
|
Loading…
Reference in New Issue