From 5d14b8d254630f4dd566bfa730b7a49b4995856d Mon Sep 17 00:00:00 2001 From: RainbowMango Date: Thu, 11 Jul 2024 15:07:49 +0800 Subject: [PATCH] Adopt deprecated AddToScheme functions Signed-off-by: RainbowMango --- pkg/apis/cluster/install/install.go | 5 ++-- pkg/apis/search/install/install.go | 5 ++-- .../customized/webhook/customized.go | 9 +++++-- pkg/util/gclient/gclient.go | 26 +++++++++---------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/pkg/apis/cluster/install/install.go b/pkg/apis/cluster/install/install.go index dc21685d3..fdd15f601 100644 --- a/pkg/apis/cluster/install/install.go +++ b/pkg/apis/cluster/install/install.go @@ -18,6 +18,7 @@ package install import ( "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "github.com/karmada-io/karmada/pkg/apis/cluster" @@ -27,6 +28,6 @@ import ( // Install registers the API group and adds types to a scheme. func Install(scheme *runtime.Scheme) { utilruntime.Must(cluster.AddToScheme(scheme)) - utilruntime.Must(clusterv1alpha1.AddToScheme(scheme)) - utilruntime.Must(scheme.SetVersionPriority(clusterv1alpha1.SchemeGroupVersion)) + utilruntime.Must(clusterv1alpha1.Install(scheme)) + utilruntime.Must(scheme.SetVersionPriority(schema.GroupVersion{Group: clusterv1alpha1.GroupVersion.Group, Version: clusterv1alpha1.GroupVersion.Version})) } diff --git a/pkg/apis/search/install/install.go b/pkg/apis/search/install/install.go index 9e59690fb..e3914703e 100644 --- a/pkg/apis/search/install/install.go +++ b/pkg/apis/search/install/install.go @@ -18,6 +18,7 @@ package install import ( "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "github.com/karmada-io/karmada/pkg/apis/search" @@ -27,6 +28,6 @@ import ( // Install registers the API group and adds types to a scheme. func Install(scheme *runtime.Scheme) { utilruntime.Must(search.AddToScheme(scheme)) - utilruntime.Must(searchv1alpha1.AddToScheme(scheme)) - utilruntime.Must(scheme.SetVersionPriority(searchv1alpha1.SchemeGroupVersion)) + utilruntime.Must(searchv1alpha1.Install(scheme)) + utilruntime.Must(scheme.SetVersionPriority(schema.GroupVersion{Group: searchv1alpha1.GroupVersion.Group, Version: searchv1alpha1.GroupVersion.Version})) } diff --git a/pkg/resourceinterpreter/customized/webhook/customized.go b/pkg/resourceinterpreter/customized/webhook/customized.go index 89a2514c0..efa8e7cd1 100644 --- a/pkg/resourceinterpreter/customized/webhook/customized.go +++ b/pkg/resourceinterpreter/customized/webhook/customized.go @@ -53,8 +53,13 @@ type CustomizedInterpreter struct { // NewCustomizedInterpreter return a new CustomizedInterpreter. func NewCustomizedInterpreter(informer genericmanager.SingleClusterInformerManager, serviceLister corev1.ServiceLister) (*CustomizedInterpreter, error) { cm, err := webhookutil.NewClientManager( - []schema.GroupVersion{configv1alpha1.SchemeGroupVersion}, - configv1alpha1.AddToScheme, + []schema.GroupVersion{ + { + Group: configv1alpha1.GroupVersion.Group, + Version: configv1alpha1.GroupVersion.Version, + }, + }, + configv1alpha1.Install, ) if err != nil { return nil, err diff --git a/pkg/util/gclient/gclient.go b/pkg/util/gclient/gclient.go index 6e7a99a18..b8faf7831 100644 --- a/pkg/util/gclient/gclient.go +++ b/pkg/util/gclient/gclient.go @@ -41,19 +41,19 @@ import ( var aggregatedScheme = runtime.NewScheme() func init() { - utilruntime.Must(scheme.AddToScheme(aggregatedScheme)) // add Kubernetes schemes - utilruntime.Must(clusterv1alpha1.AddToScheme(aggregatedScheme)) // add cluster schemes - utilruntime.Must(configv1alpha1.AddToScheme(aggregatedScheme)) // add config v1alpha1 schemes - utilruntime.Must(networkingv1alpha1.AddToScheme(aggregatedScheme)) // add network v1alpha1 schemes - utilruntime.Must(policyv1alpha1.AddToScheme(aggregatedScheme)) // add propagation schemes - utilruntime.Must(workv1alpha1.AddToScheme(aggregatedScheme)) // add work v1alpha1 schemes - utilruntime.Must(workv1alpha2.AddToScheme(aggregatedScheme)) // add work v1alpha2 schemes - utilruntime.Must(searchv1alpha1.AddToScheme(aggregatedScheme)) // add search v1alpha1 schemes - utilruntime.Must(mcsv1alpha1.AddToScheme(aggregatedScheme)) // add mcs-api schemes - utilruntime.Must(clusterapiv1beta1.AddToScheme(aggregatedScheme)) // add cluster-api v1beta1 schemes - utilruntime.Must(autoscalingv1alpha1.AddToScheme(aggregatedScheme)) // add autoscaling v1alpha1 schemes - utilruntime.Must(remedyv1alpha1.AddToScheme(aggregatedScheme)) // add remedy v1alpha1 schemes - utilruntime.Must(appsv1alpha1.AddToScheme(aggregatedScheme)) // add apps v1alpha1 schemes + utilruntime.Must(scheme.AddToScheme(aggregatedScheme)) // add Kubernetes schemes + utilruntime.Must(clusterv1alpha1.Install(aggregatedScheme)) // add cluster schemes + utilruntime.Must(configv1alpha1.Install(aggregatedScheme)) // add config v1alpha1 schemes + utilruntime.Must(networkingv1alpha1.Install(aggregatedScheme)) // add network v1alpha1 schemes + utilruntime.Must(policyv1alpha1.Install(aggregatedScheme)) // add propagation schemes + utilruntime.Must(workv1alpha1.Install(aggregatedScheme)) // add work v1alpha1 schemes + utilruntime.Must(workv1alpha2.Install(aggregatedScheme)) // add work v1alpha2 schemes + utilruntime.Must(searchv1alpha1.Install(aggregatedScheme)) // add search v1alpha1 schemes + utilruntime.Must(mcsv1alpha1.Install(aggregatedScheme)) // add mcs-api schemes + utilruntime.Must(autoscalingv1alpha1.Install(aggregatedScheme)) // add autoscaling v1alpha1 schemes + utilruntime.Must(remedyv1alpha1.Install(aggregatedScheme)) // add remedy v1alpha1 schemes + utilruntime.Must(appsv1alpha1.Install(aggregatedScheme)) // add apps v1alpha1 schemes + utilruntime.Must(clusterapiv1beta1.AddToScheme(aggregatedScheme)) // add cluster-api v1beta1 schemes } // NewSchema returns a singleton schema set which aggregated Kubernetes's schemes and extended schemes.