From e8164eeebd72371432c94ae33c5c3e8d4f87ebb5 Mon Sep 17 00:00:00 2001 From: RainbowMango Date: Thu, 11 Jul 2024 11:09:35 +0800 Subject: [PATCH] Adopt controller-runtime braking changes: generics support PR2783 Adopt controller-runtime breaking changes: make decoder as interface. PR2736 Signed-off-by: RainbowMango --- pkg/controllers/remediation/eventhandlers.go | 110 ++++++++++-------- .../remediation/eventhandlers_test.go | 26 ++--- .../remediation/remedy_controller.go | 8 +- .../dependencies_distributor.go | 8 +- .../clusteroverridepolicy/validating.go | 2 +- .../clusterpropagationpolicy/mutating.go | 4 +- .../clusterpropagationpolicy/validating.go | 2 +- .../clusterresourcebinding/mutating.go | 2 +- pkg/webhook/configuration/validating.go | 2 +- pkg/webhook/cronfederatedhpa/validating.go | 2 +- pkg/webhook/federatedhpa/mutating.go | 2 +- pkg/webhook/federatedhpa/validating.go | 2 +- .../federatedresourcequota/validating.go | 2 +- pkg/webhook/multiclusteringress/validating.go | 2 +- pkg/webhook/multiclusterservice/mutating.go | 2 +- pkg/webhook/multiclusterservice/validating.go | 2 +- pkg/webhook/overridepolicy/mutating.go | 2 +- pkg/webhook/overridepolicy/validating.go | 2 +- pkg/webhook/propagationpolicy/mutating.go | 4 +- pkg/webhook/propagationpolicy/validating.go | 2 +- pkg/webhook/resourcebinding/mutating.go | 2 +- .../resourcedeletionprotection/validating.go | 2 +- .../validating.go | 2 +- pkg/webhook/work/mutating.go | 2 +- 24 files changed, 105 insertions(+), 91 deletions(-) diff --git a/pkg/controllers/remediation/eventhandlers.go b/pkg/controllers/remediation/eventhandlers.go index a97e31acb..dd51fef9f 100644 --- a/pkg/controllers/remediation/eventhandlers.go +++ b/pkg/controllers/remediation/eventhandlers.go @@ -34,64 +34,63 @@ import ( remedyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/remedy/v1alpha1" ) -func newClusterEventHandler() handler.EventHandler { +func newClusterEventHandler() handler.TypedEventHandler[*clusterv1alpha1.Cluster] { return &clusterEventHandler{} } -var _ handler.EventHandler = (*clusterEventHandler)(nil) +var _ handler.TypedEventHandler[*clusterv1alpha1.Cluster] = &clusterEventHandler{} -type clusterEventHandler struct { -} +type clusterEventHandler struct{} -func (h *clusterEventHandler) Create(_ context.Context, _ event.CreateEvent, _ workqueue.RateLimitingInterface) { +func (h *clusterEventHandler) Create(context.Context, event.TypedCreateEvent[*clusterv1alpha1.Cluster], workqueue.RateLimitingInterface) { // Don't care about cluster creation events } -func (h *clusterEventHandler) Update(_ context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) { - oldCluster := e.ObjectOld.(*clusterv1alpha1.Cluster) - newCluster := e.ObjectNew.(*clusterv1alpha1.Cluster) - - if reflect.DeepEqual(oldCluster.Status.Conditions, newCluster.Status.Conditions) { +func (h *clusterEventHandler) Update(_ context.Context, e event.TypedUpdateEvent[*clusterv1alpha1.Cluster], queue workqueue.RateLimitingInterface) { + if reflect.DeepEqual(e.ObjectOld.Status.Conditions, e.ObjectNew.Status.Conditions) { return } queue.Add(reconcile.Request{NamespacedName: types.NamespacedName{ - Name: newCluster.Name, + Name: e.ObjectNew.Name, }}) } -func (h *clusterEventHandler) Delete(_ context.Context, _ event.DeleteEvent, _ workqueue.RateLimitingInterface) { +func (h *clusterEventHandler) Delete(_ context.Context, _ event.TypedDeleteEvent[*clusterv1alpha1.Cluster], _ workqueue.RateLimitingInterface) { // Don't care about cluster deletion events } -func (h *clusterEventHandler) Generic(_ context.Context, e event.GenericEvent, queue workqueue.RateLimitingInterface) { +func (h *clusterEventHandler) Generic(_ context.Context, e event.TypedGenericEvent[*clusterv1alpha1.Cluster], queue workqueue.RateLimitingInterface) { queue.Add(reconcile.Request{NamespacedName: types.NamespacedName{ Name: e.Object.GetName(), }}) } -func newRemedyEventHandler(clusterChan chan<- event.GenericEvent, client client.Client) handler.EventHandler { +func newRemedyEventHandler(clusterChan chan<- event.TypedGenericEvent[*clusterv1alpha1.Cluster], client client.Client) handler.TypedEventHandler[*remedyv1alpha1.Remedy] { return &remedyEventHandler{ client: client, clusterChan: clusterChan, } } -var _ handler.EventHandler = (*remedyEventHandler)(nil) +var _ handler.TypedEventHandler[*remedyv1alpha1.Remedy] = &remedyEventHandler{} type remedyEventHandler struct { client client.Client - clusterChan chan<- event.GenericEvent + clusterChan chan<- event.TypedGenericEvent[*clusterv1alpha1.Cluster] } -func (h *remedyEventHandler) Create(ctx context.Context, e event.CreateEvent, _ workqueue.RateLimitingInterface) { - remedy := e.Object.(*remedyv1alpha1.Remedy) +func (h *remedyEventHandler) Create(ctx context.Context, e event.TypedCreateEvent[*remedyv1alpha1.Remedy], _ workqueue.RateLimitingInterface) { + remedy := e.Object if remedy.Spec.ClusterAffinity != nil { for _, clusterName := range remedy.Spec.ClusterAffinity.ClusterNames { - h.clusterChan <- event.GenericEvent{Object: &clusterv1alpha1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterName, - }}} + h.clusterChan <- event.TypedGenericEvent[*clusterv1alpha1.Cluster]{ + Object: &clusterv1alpha1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterName, + }, + }, + } } return } @@ -104,16 +103,19 @@ func (h *remedyEventHandler) Create(ctx context.Context, e event.CreateEvent, _ } for _, cluster := range clusterList.Items { - h.clusterChan <- event.GenericEvent{Object: &clusterv1alpha1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - }}} + h.clusterChan <- event.TypedGenericEvent[*clusterv1alpha1.Cluster]{ + Object: &clusterv1alpha1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: cluster.Name, + }, + }, + } } } -func (h *remedyEventHandler) Update(ctx context.Context, e event.UpdateEvent, _ workqueue.RateLimitingInterface) { - oldRemedy := e.ObjectOld.(*remedyv1alpha1.Remedy) - newRemedy := e.ObjectNew.(*remedyv1alpha1.Remedy) +func (h *remedyEventHandler) Update(ctx context.Context, e event.TypedUpdateEvent[*remedyv1alpha1.Remedy], _ workqueue.RateLimitingInterface) { + oldRemedy := e.ObjectOld + newRemedy := e.ObjectNew if oldRemedy.Spec.ClusterAffinity == nil || newRemedy.Spec.ClusterAffinity == nil { clusterList := &clusterv1alpha1.ClusterList{} @@ -124,10 +126,13 @@ func (h *remedyEventHandler) Update(ctx context.Context, e event.UpdateEvent, _ } for _, cluster := range clusterList.Items { - h.clusterChan <- event.GenericEvent{Object: &clusterv1alpha1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - }}} + h.clusterChan <- event.TypedGenericEvent[*clusterv1alpha1.Cluster]{ + Object: &clusterv1alpha1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: cluster.Name, + }, + }, + } } return } @@ -140,21 +145,27 @@ func (h *remedyEventHandler) Update(ctx context.Context, e event.UpdateEvent, _ clusters.Insert(clusterName) } for clusterName := range clusters { - h.clusterChan <- event.GenericEvent{Object: &clusterv1alpha1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterName, - }}} + h.clusterChan <- event.TypedGenericEvent[*clusterv1alpha1.Cluster]{ + Object: &clusterv1alpha1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterName, + }, + }, + } } } -func (h *remedyEventHandler) Delete(ctx context.Context, e event.DeleteEvent, _ workqueue.RateLimitingInterface) { - remedy := e.Object.(*remedyv1alpha1.Remedy) +func (h *remedyEventHandler) Delete(ctx context.Context, e event.TypedDeleteEvent[*remedyv1alpha1.Remedy], _ workqueue.RateLimitingInterface) { + remedy := e.Object if remedy.Spec.ClusterAffinity != nil { for _, clusterName := range remedy.Spec.ClusterAffinity.ClusterNames { - h.clusterChan <- event.GenericEvent{Object: &clusterv1alpha1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterName, - }}} + h.clusterChan <- event.TypedGenericEvent[*clusterv1alpha1.Cluster]{ + Object: &clusterv1alpha1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterName, + }, + }, + } } return } @@ -167,12 +178,15 @@ func (h *remedyEventHandler) Delete(ctx context.Context, e event.DeleteEvent, _ } for _, cluster := range clusterList.Items { - h.clusterChan <- event.GenericEvent{Object: &clusterv1alpha1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - }}} + h.clusterChan <- event.TypedGenericEvent[*clusterv1alpha1.Cluster]{ + Object: &clusterv1alpha1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: cluster.Name, + }, + }, + } } } -func (h *remedyEventHandler) Generic(_ context.Context, _ event.GenericEvent, _ workqueue.RateLimitingInterface) { +func (h *remedyEventHandler) Generic(_ context.Context, _ event.TypedGenericEvent[*remedyv1alpha1.Remedy], _ workqueue.RateLimitingInterface) { } diff --git a/pkg/controllers/remediation/eventhandlers_test.go b/pkg/controllers/remediation/eventhandlers_test.go index ca8eadf69..dcbba6703 100644 --- a/pkg/controllers/remediation/eventhandlers_test.go +++ b/pkg/controllers/remediation/eventhandlers_test.go @@ -36,8 +36,8 @@ func Test_clusterEventHandler(t *testing.T) { type args struct { operation string q workqueue.RateLimitingInterface - obj client.Object - oldObj client.Object + obj *clusterv1alpha1.Cluster + oldObj *clusterv1alpha1.Cluster } tests := []struct { name string @@ -144,16 +144,16 @@ func Test_clusterEventHandler(t *testing.T) { h := newClusterEventHandler() switch tt.args.operation { case "Create": - createEvent := event.CreateEvent{Object: tt.args.obj} + createEvent := event.TypedCreateEvent[*clusterv1alpha1.Cluster]{Object: tt.args.obj} h.Create(context.TODO(), createEvent, queue) case "Delete": - deleteEvent := event.DeleteEvent{Object: tt.args.obj} + deleteEvent := event.TypedDeleteEvent[*clusterv1alpha1.Cluster]{Object: tt.args.obj} h.Delete(context.TODO(), deleteEvent, queue) case "Update": - updateEvent := event.UpdateEvent{ObjectNew: tt.args.obj, ObjectOld: tt.args.oldObj} + updateEvent := event.TypedUpdateEvent[*clusterv1alpha1.Cluster]{ObjectNew: tt.args.obj, ObjectOld: tt.args.oldObj} h.Update(context.TODO(), updateEvent, queue) case "Generic": - genericEvent := event.GenericEvent{Object: tt.args.obj} + genericEvent := event.TypedGenericEvent[*clusterv1alpha1.Cluster]{Object: tt.args.obj} h.Generic(context.TODO(), genericEvent, queue) default: t.Errorf("no support operation %v", tt.args.operation) @@ -170,8 +170,8 @@ func Test_clusterEventHandler(t *testing.T) { func Test_remedyEventHandler(t *testing.T) { type args struct { operation string - obj client.Object - oldObj client.Object + obj *remedyv1alpha1.Remedy + oldObj *remedyv1alpha1.Remedy client client.Client } tests := []struct { @@ -328,30 +328,30 @@ func Test_remedyEventHandler(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - clusterChan := make(chan event.GenericEvent) + clusterChan := make(chan event.TypedGenericEvent[*clusterv1alpha1.Cluster]) h := newRemedyEventHandler(clusterChan, tt.args.client) switch tt.args.operation { case "Create": go func() { - createEvent := event.CreateEvent{Object: tt.args.obj} + createEvent := event.TypedCreateEvent[*remedyv1alpha1.Remedy]{Object: tt.args.obj} h.Create(context.TODO(), createEvent, nil) close(clusterChan) }() case "Delete": go func() { - deleteEvent := event.DeleteEvent{Object: tt.args.obj} + deleteEvent := event.TypedDeleteEvent[*remedyv1alpha1.Remedy]{Object: tt.args.obj} h.Delete(context.TODO(), deleteEvent, nil) close(clusterChan) }() case "Update": go func() { - updateEvent := event.UpdateEvent{ObjectNew: tt.args.obj, ObjectOld: tt.args.oldObj} + updateEvent := event.TypedUpdateEvent[*remedyv1alpha1.Remedy]{ObjectNew: tt.args.obj, ObjectOld: tt.args.oldObj} h.Update(context.TODO(), updateEvent, nil) close(clusterChan) }() case "Generic": go func() { - genericEvent := event.GenericEvent{Object: tt.args.obj} + genericEvent := event.TypedGenericEvent[*remedyv1alpha1.Remedy]{Object: tt.args.obj} h.Generic(context.TODO(), genericEvent, nil) close(clusterChan) }() diff --git a/pkg/controllers/remediation/remedy_controller.go b/pkg/controllers/remediation/remedy_controller.go index 19688765c..baea6f262 100644 --- a/pkg/controllers/remediation/remedy_controller.go +++ b/pkg/controllers/remediation/remedy_controller.go @@ -101,17 +101,17 @@ func (c *RemedyController) SetupWithManager(mgr controllerruntime.Manager) error } func (c *RemedyController) setupWatches(remedyController controller.Controller, mgr controllerruntime.Manager) error { - clusterChan := make(chan event.GenericEvent) + clusterChan := make(chan event.TypedGenericEvent[*clusterv1alpha1.Cluster]) clusterHandler := newClusterEventHandler() remedyHandler := newRemedyEventHandler(clusterChan, c.Client) - if err := remedyController.Watch(source.Kind(mgr.GetCache(), &clusterv1alpha1.Cluster{}), clusterHandler); err != nil { + if err := remedyController.Watch(source.Kind[*clusterv1alpha1.Cluster](mgr.GetCache(), &clusterv1alpha1.Cluster{}, clusterHandler)); err != nil { return err } - if err := remedyController.Watch(&source.Channel{Source: clusterChan}, clusterHandler); err != nil { + if err := remedyController.Watch(source.Channel(clusterChan, clusterHandler)); err != nil { return err } - if err := remedyController.Watch(source.Kind(mgr.GetCache(), &remedyv1alpha1.Remedy{}), remedyHandler); err != nil { + if err := remedyController.Watch(source.Kind(mgr.GetCache(), &remedyv1alpha1.Remedy{}, remedyHandler)); err != nil { return err } return nil diff --git a/pkg/dependenciesdistributor/dependencies_distributor.go b/pkg/dependenciesdistributor/dependencies_distributor.go index ee53a7130..981b9bc60 100644 --- a/pkg/dependenciesdistributor/dependencies_distributor.go +++ b/pkg/dependenciesdistributor/dependencies_distributor.go @@ -103,7 +103,7 @@ type DependenciesDistributor struct { eventHandler cache.ResourceEventHandler resourceProcessor util.AsyncWorker - genericEvent chan event.GenericEvent + genericEvent chan event.TypedGenericEvent[*workv1alpha2.ResourceBinding] stopCh <-chan struct{} } @@ -184,7 +184,7 @@ func (d *DependenciesDistributor) reconcileResourceTemplate(key util.QueueKey) e } klog.V(4).Infof("ResourceBinding(%s/%s) is matched for resource(%s/%s)", binding.Namespace, binding.Name, resourceTemplateKey.Namespace, resourceTemplateKey.Name) - d.genericEvent <- event.GenericEvent{Object: binding} + d.genericEvent <- event.TypedGenericEvent[*workv1alpha2.ResourceBinding]{Object: binding} } return nil @@ -610,7 +610,7 @@ func (d *DependenciesDistributor) Start(ctx context.Context) error { // SetupWithManager creates a controller and register to controller manager. func (d *DependenciesDistributor) SetupWithManager(mgr controllerruntime.Manager) error { - d.genericEvent = make(chan event.GenericEvent) + d.genericEvent = make(chan event.TypedGenericEvent[*workv1alpha2.ResourceBinding]) return utilerrors.NewAggregate([]error{ mgr.Add(d), controllerruntime.NewControllerManagedBy(mgr).For(&workv1alpha2.ResourceBinding{}). @@ -650,7 +650,7 @@ func (d *DependenciesDistributor) SetupWithManager(mgr controllerruntime.Manager RateLimiter: ratelimiterflag.DefaultControllerRateLimiter(d.RateLimiterOptions), MaxConcurrentReconciles: 2, }). - WatchesRawSource(&source.Channel{Source: d.genericEvent}, &handler.EnqueueRequestForObject{}). + WatchesRawSource(source.Channel(d.genericEvent, &handler.TypedEnqueueRequestForObject[*workv1alpha2.ResourceBinding]{})). Complete(d), }) } diff --git a/pkg/webhook/clusteroverridepolicy/validating.go b/pkg/webhook/clusteroverridepolicy/validating.go index 4e7323386..34db89bc8 100644 --- a/pkg/webhook/clusteroverridepolicy/validating.go +++ b/pkg/webhook/clusteroverridepolicy/validating.go @@ -29,7 +29,7 @@ import ( // ValidatingAdmission validates ClusterOverridePolicy object when creating/updating/deleting. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/clusterpropagationpolicy/mutating.go b/pkg/webhook/clusterpropagationpolicy/mutating.go index cf76ba4c7..2905637d1 100644 --- a/pkg/webhook/clusterpropagationpolicy/mutating.go +++ b/pkg/webhook/clusterpropagationpolicy/mutating.go @@ -35,7 +35,7 @@ import ( // MutatingAdmission mutates API request if necessary. type MutatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder DefaultNotReadyTolerationSeconds int64 DefaultUnreachableTolerationSeconds int64 @@ -45,7 +45,7 @@ type MutatingAdmission struct { var _ admission.Handler = &MutatingAdmission{} // NewMutatingHandler builds a new admission.Handler. -func NewMutatingHandler(notReadyTolerationSeconds, unreachableTolerationSeconds int64, decoder *admission.Decoder) admission.Handler { +func NewMutatingHandler(notReadyTolerationSeconds, unreachableTolerationSeconds int64, decoder admission.Decoder) admission.Handler { return &MutatingAdmission{ DefaultNotReadyTolerationSeconds: notReadyTolerationSeconds, DefaultUnreachableTolerationSeconds: unreachableTolerationSeconds, diff --git a/pkg/webhook/clusterpropagationpolicy/validating.go b/pkg/webhook/clusterpropagationpolicy/validating.go index 2933a954d..3f4ac05db 100644 --- a/pkg/webhook/clusterpropagationpolicy/validating.go +++ b/pkg/webhook/clusterpropagationpolicy/validating.go @@ -31,7 +31,7 @@ import ( // ValidatingAdmission validates ClusterPropagationPolicy object when creating/updating/deleting. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/clusterresourcebinding/mutating.go b/pkg/webhook/clusterresourcebinding/mutating.go index 91b3cc0cc..c6ad64486 100644 --- a/pkg/webhook/clusterresourcebinding/mutating.go +++ b/pkg/webhook/clusterresourcebinding/mutating.go @@ -31,7 +31,7 @@ import ( // MutatingAdmission mutates API request if necessary. type MutatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our MutatingAdmission implements necessary interface diff --git a/pkg/webhook/configuration/validating.go b/pkg/webhook/configuration/validating.go index 06c07ac75..7c86aef86 100644 --- a/pkg/webhook/configuration/validating.go +++ b/pkg/webhook/configuration/validating.go @@ -34,7 +34,7 @@ import ( // ValidatingAdmission validates ResourceInterpreterWebhookConfiguration object when creating/updating. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/cronfederatedhpa/validating.go b/pkg/webhook/cronfederatedhpa/validating.go index e1b6385e2..f769f65c7 100755 --- a/pkg/webhook/cronfederatedhpa/validating.go +++ b/pkg/webhook/cronfederatedhpa/validating.go @@ -38,7 +38,7 @@ import ( // ValidatingAdmission validates CronFederatedHPA object when creating/updating. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/federatedhpa/mutating.go b/pkg/webhook/federatedhpa/mutating.go index 9728e5a35..96e715975 100644 --- a/pkg/webhook/federatedhpa/mutating.go +++ b/pkg/webhook/federatedhpa/mutating.go @@ -30,7 +30,7 @@ import ( // MutatingAdmission mutates API request if necessary. type MutatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our MutatingAdmission implements necessary interface diff --git a/pkg/webhook/federatedhpa/validating.go b/pkg/webhook/federatedhpa/validating.go index e2636478f..f0fc69dc8 100644 --- a/pkg/webhook/federatedhpa/validating.go +++ b/pkg/webhook/federatedhpa/validating.go @@ -29,7 +29,7 @@ import ( // ValidatingAdmission validates FederatedHPA object when creating/updating. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/federatedresourcequota/validating.go b/pkg/webhook/federatedresourcequota/validating.go index 185de241b..d2b3d9a2a 100644 --- a/pkg/webhook/federatedresourcequota/validating.go +++ b/pkg/webhook/federatedresourcequota/validating.go @@ -34,7 +34,7 @@ import ( // ValidatingAdmission validates FederatedResourceQuota object when creating/updating. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/multiclusteringress/validating.go b/pkg/webhook/multiclusteringress/validating.go index ef8299775..5c1e346c1 100644 --- a/pkg/webhook/multiclusteringress/validating.go +++ b/pkg/webhook/multiclusteringress/validating.go @@ -32,7 +32,7 @@ import ( // ValidatingAdmission validates MultiClusterIngress object when creating/updating. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/multiclusterservice/mutating.go b/pkg/webhook/multiclusterservice/mutating.go index 1f16c191e..14784192c 100644 --- a/pkg/webhook/multiclusterservice/mutating.go +++ b/pkg/webhook/multiclusterservice/mutating.go @@ -30,7 +30,7 @@ import ( // MutatingAdmission mutates API request if necessary. type MutatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our MutatingAdmission implements necessary interface diff --git a/pkg/webhook/multiclusterservice/validating.go b/pkg/webhook/multiclusterservice/validating.go index 3df70e039..5343e224a 100644 --- a/pkg/webhook/multiclusterservice/validating.go +++ b/pkg/webhook/multiclusterservice/validating.go @@ -37,7 +37,7 @@ import ( // ValidatingAdmission validates MultiClusterService object when creating/updating. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/overridepolicy/mutating.go b/pkg/webhook/overridepolicy/mutating.go index f60730dc4..592b5252d 100644 --- a/pkg/webhook/overridepolicy/mutating.go +++ b/pkg/webhook/overridepolicy/mutating.go @@ -29,7 +29,7 @@ import ( // MutatingAdmission mutates API request if necessary. type MutatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our MutatingAdmission implements necessary interface diff --git a/pkg/webhook/overridepolicy/validating.go b/pkg/webhook/overridepolicy/validating.go index 6fec6797c..b261c31f6 100644 --- a/pkg/webhook/overridepolicy/validating.go +++ b/pkg/webhook/overridepolicy/validating.go @@ -29,7 +29,7 @@ import ( // ValidatingAdmission validates OverridePolicy object when creating/updating/deleting. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/propagationpolicy/mutating.go b/pkg/webhook/propagationpolicy/mutating.go index 298fba279..98d8185dd 100644 --- a/pkg/webhook/propagationpolicy/mutating.go +++ b/pkg/webhook/propagationpolicy/mutating.go @@ -36,7 +36,7 @@ import ( // MutatingAdmission mutates API request if necessary. type MutatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder DefaultNotReadyTolerationSeconds int64 DefaultUnreachableTolerationSeconds int64 @@ -46,7 +46,7 @@ type MutatingAdmission struct { var _ admission.Handler = &MutatingAdmission{} // NewMutatingHandler builds a new admission.Handler. -func NewMutatingHandler(notReadyTolerationSeconds, unreachableTolerationSeconds int64, decoder *admission.Decoder) admission.Handler { +func NewMutatingHandler(notReadyTolerationSeconds, unreachableTolerationSeconds int64, decoder admission.Decoder) admission.Handler { return &MutatingAdmission{ DefaultNotReadyTolerationSeconds: notReadyTolerationSeconds, DefaultUnreachableTolerationSeconds: unreachableTolerationSeconds, diff --git a/pkg/webhook/propagationpolicy/validating.go b/pkg/webhook/propagationpolicy/validating.go index 93908143e..f7ed399d9 100644 --- a/pkg/webhook/propagationpolicy/validating.go +++ b/pkg/webhook/propagationpolicy/validating.go @@ -31,7 +31,7 @@ import ( // ValidatingAdmission validates PropagationPolicy object when creating/updating/deleting. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/resourcebinding/mutating.go b/pkg/webhook/resourcebinding/mutating.go index 7e196883a..497c40ea0 100644 --- a/pkg/webhook/resourcebinding/mutating.go +++ b/pkg/webhook/resourcebinding/mutating.go @@ -31,7 +31,7 @@ import ( // MutatingAdmission mutates API request if necessary. type MutatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our MutatingAdmission implements necessary interface diff --git a/pkg/webhook/resourcedeletionprotection/validating.go b/pkg/webhook/resourcedeletionprotection/validating.go index d2fb0b52b..33111d67d 100755 --- a/pkg/webhook/resourcedeletionprotection/validating.go +++ b/pkg/webhook/resourcedeletionprotection/validating.go @@ -31,7 +31,7 @@ import ( // ValidatingAdmission validates resource templates to ensure those protected resources are not delectable. type ValidatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/resourceinterpretercustomization/validating.go b/pkg/webhook/resourceinterpretercustomization/validating.go index 4c0b3a454..a6c861a7b 100644 --- a/pkg/webhook/resourceinterpretercustomization/validating.go +++ b/pkg/webhook/resourceinterpretercustomization/validating.go @@ -30,7 +30,7 @@ import ( // ValidatingAdmission validates ResourceInterpreterCustomization object when creating/updating. type ValidatingAdmission struct { client.Client - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our ValidatingAdmission implements necessary interface diff --git a/pkg/webhook/work/mutating.go b/pkg/webhook/work/mutating.go index 0dc28f2e6..bc0b72df4 100644 --- a/pkg/webhook/work/mutating.go +++ b/pkg/webhook/work/mutating.go @@ -35,7 +35,7 @@ import ( // MutatingAdmission mutates API request if necessary. type MutatingAdmission struct { - Decoder *admission.Decoder + Decoder admission.Decoder } // Check if our MutatingAdmission implements necessary interface