mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #82921 from wojtek-t/cleanup_meta_v1
Minor cleanup meta v1/v1beta1 and register DeleteOptions
This commit is contained in:
commit
e1f2494358
@ -35,6 +35,8 @@ func AddConversionFuncs(scheme *runtime.Scheme) error {
|
|||||||
|
|
||||||
Convert_v1_ListMeta_To_v1_ListMeta,
|
Convert_v1_ListMeta_To_v1_ListMeta,
|
||||||
|
|
||||||
|
Convert_v1_DeleteOptions_To_v1_DeleteOptions,
|
||||||
|
|
||||||
Convert_intstr_IntOrString_To_intstr_IntOrString,
|
Convert_intstr_IntOrString_To_intstr_IntOrString,
|
||||||
Convert_Pointer_intstr_IntOrString_To_intstr_IntOrString,
|
Convert_Pointer_intstr_IntOrString_To_intstr_IntOrString,
|
||||||
Convert_intstr_IntOrString_To_Pointer_intstr_IntOrString,
|
Convert_intstr_IntOrString_To_Pointer_intstr_IntOrString,
|
||||||
|
@ -40,6 +40,31 @@ func Kind(kind string) schema.GroupKind {
|
|||||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scheme is the registry for the common types that adhere to the meta v1 API spec.
|
||||||
|
var scheme = runtime.NewScheme()
|
||||||
|
|
||||||
|
// ParameterCodec knows about query parameters used with the meta v1 API spec.
|
||||||
|
var ParameterCodec = runtime.NewParameterCodec(scheme)
|
||||||
|
|
||||||
|
func addEventConversionFuncs(scheme *runtime.Scheme) error {
|
||||||
|
return scheme.AddConversionFuncs(
|
||||||
|
Convert_v1_WatchEvent_To_watch_Event,
|
||||||
|
Convert_v1_InternalEvent_To_v1_WatchEvent,
|
||||||
|
Convert_watch_Event_To_v1_WatchEvent,
|
||||||
|
Convert_v1_WatchEvent_To_v1_InternalEvent,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
var optionsTypes = []runtime.Object{
|
||||||
|
&ListOptions{},
|
||||||
|
&ExportOptions{},
|
||||||
|
&GetOptions{},
|
||||||
|
&DeleteOptions{},
|
||||||
|
&CreateOptions{},
|
||||||
|
&UpdateOptions{},
|
||||||
|
&PatchOptions{},
|
||||||
|
}
|
||||||
|
|
||||||
// AddToGroupVersion registers common meta types into schemas.
|
// AddToGroupVersion registers common meta types into schemas.
|
||||||
func AddToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion) {
|
func AddToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion) {
|
||||||
scheme.AddKnownTypeWithName(groupVersion.WithKind(WatchEventKind), &WatchEvent{})
|
scheme.AddKnownTypeWithName(groupVersion.WithKind(WatchEventKind), &WatchEvent{})
|
||||||
@ -48,21 +73,7 @@ func AddToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion)
|
|||||||
&InternalEvent{},
|
&InternalEvent{},
|
||||||
)
|
)
|
||||||
// Supports legacy code paths, most callers should use metav1.ParameterCodec for now
|
// Supports legacy code paths, most callers should use metav1.ParameterCodec for now
|
||||||
scheme.AddKnownTypes(groupVersion,
|
scheme.AddKnownTypes(groupVersion, optionsTypes...)
|
||||||
&ListOptions{},
|
|
||||||
&ExportOptions{},
|
|
||||||
&GetOptions{},
|
|
||||||
&DeleteOptions{},
|
|
||||||
&CreateOptions{},
|
|
||||||
&UpdateOptions{},
|
|
||||||
&PatchOptions{},
|
|
||||||
)
|
|
||||||
utilruntime.Must(scheme.AddConversionFuncs(
|
|
||||||
Convert_v1_WatchEvent_To_watch_Event,
|
|
||||||
Convert_v1_InternalEvent_To_v1_WatchEvent,
|
|
||||||
Convert_watch_Event_To_v1_WatchEvent,
|
|
||||||
Convert_v1_WatchEvent_To_v1_InternalEvent,
|
|
||||||
))
|
|
||||||
// Register Unversioned types under their own special group
|
// Register Unversioned types under their own special group
|
||||||
scheme.AddUnversionedTypes(Unversioned,
|
scheme.AddUnversionedTypes(Unversioned,
|
||||||
&Status{},
|
&Status{},
|
||||||
@ -72,36 +83,14 @@ func AddToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion)
|
|||||||
&APIResourceList{},
|
&APIResourceList{},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
utilruntime.Must(addEventConversionFuncs(scheme))
|
||||||
|
|
||||||
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
|
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
|
||||||
utilruntime.Must(AddConversionFuncs(scheme))
|
utilruntime.Must(AddConversionFuncs(scheme))
|
||||||
utilruntime.Must(RegisterDefaults(scheme))
|
utilruntime.Must(RegisterDefaults(scheme))
|
||||||
}
|
}
|
||||||
|
|
||||||
// scheme is the registry for the common types that adhere to the meta v1 API spec.
|
// AddMetaToScheme registers base meta types into schemas.
|
||||||
var scheme = runtime.NewScheme()
|
|
||||||
|
|
||||||
// ParameterCodec knows about query parameters used with the meta v1 API spec.
|
|
||||||
var ParameterCodec = runtime.NewParameterCodec(scheme)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
scheme.AddUnversionedTypes(SchemeGroupVersion,
|
|
||||||
&ListOptions{},
|
|
||||||
&ExportOptions{},
|
|
||||||
&GetOptions{},
|
|
||||||
&DeleteOptions{},
|
|
||||||
&CreateOptions{},
|
|
||||||
&UpdateOptions{},
|
|
||||||
&PatchOptions{},
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := AddMetaToScheme(scheme); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
|
|
||||||
utilruntime.Must(RegisterDefaults(scheme))
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddMetaToScheme(scheme *runtime.Scheme) error {
|
func AddMetaToScheme(scheme *runtime.Scheme) error {
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
&Table{},
|
&Table{},
|
||||||
@ -114,3 +103,12 @@ func AddMetaToScheme(scheme *runtime.Scheme) error {
|
|||||||
Convert_Slice_string_To_v1_IncludeObjectPolicy,
|
Convert_Slice_string_To_v1_IncludeObjectPolicy,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
scheme.AddUnversionedTypes(SchemeGroupVersion, optionsTypes...)
|
||||||
|
|
||||||
|
utilruntime.Must(AddMetaToScheme(scheme))
|
||||||
|
|
||||||
|
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
|
||||||
|
utilruntime.Must(RegisterDefaults(scheme))
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
"//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:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
|
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -19,6 +19,7 @@ package v1beta1
|
|||||||
import (
|
import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GroupName is the group name for this API.
|
// GroupName is the group name for this API.
|
||||||
@ -38,12 +39,7 @@ var scheme = runtime.NewScheme()
|
|||||||
// ParameterCodec knows about query parameters used with the meta v1beta1 API spec.
|
// ParameterCodec knows about query parameters used with the meta v1beta1 API spec.
|
||||||
var ParameterCodec = runtime.NewParameterCodec(scheme)
|
var ParameterCodec = runtime.NewParameterCodec(scheme)
|
||||||
|
|
||||||
func init() {
|
// AddMetaToScheme registers base meta types into schemas.
|
||||||
if err := AddMetaToScheme(scheme); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddMetaToScheme(scheme *runtime.Scheme) error {
|
func AddMetaToScheme(scheme *runtime.Scheme) error {
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
&Table{},
|
&Table{},
|
||||||
@ -55,7 +51,11 @@ func AddMetaToScheme(scheme *runtime.Scheme) error {
|
|||||||
return scheme.AddConversionFuncs(
|
return scheme.AddConversionFuncs(
|
||||||
Convert_Slice_string_To_v1beta1_IncludeObjectPolicy,
|
Convert_Slice_string_To_v1beta1_IncludeObjectPolicy,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
utilruntime.Must(AddMetaToScheme(scheme))
|
||||||
|
|
||||||
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
|
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
|
||||||
//scheme.AddGeneratedDeepCopyFuncs(GetGeneratedDeepCopyFuncs()...)
|
utilruntime.Must(RegisterDefaults(scheme))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user