From 7f4d3ef0bfc1798a7a600b239d7f34e9df778cb9 Mon Sep 17 00:00:00 2001 From: Mulham Raee Date: Thu, 5 Oct 2023 13:11:35 +0200 Subject: [PATCH] adapt code after CAPI bump to v1.5.0 --- ...ontrolplane.cluster.x-k8s.io_rosacontrolplanes.yaml | 3 +-- .../infrastructure.cluster.x-k8s.io_rosaclusters.yaml | 3 +-- controllers/rosacluster_controller.go | 10 +++++----- .../rosa/controllers/rosacontrolplane_controller.go | 10 +++++----- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml b/config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml index 63610e1910..3d5c7e6a36 100644 --- a/config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml +++ b/config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.12.1 name: rosacontrolplanes.controlplane.cluster.x-k8s.io spec: group: controlplane.cluster.x-k8s.io diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_rosaclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_rosaclusters.yaml index 0c330f623d..7d0a510d34 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_rosaclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_rosaclusters.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.12.1 name: rosaclusters.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/controllers/rosacluster_controller.go b/controllers/rosacluster_controller.go index 76c0012a1c..40644abd09 100644 --- a/controllers/rosacluster_controller.go +++ b/controllers/rosacluster_controller.go @@ -135,7 +135,7 @@ func (r *ROSAClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M // Add a watch for clusterv1.Cluster unpaise if err = controller.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("ROSACluster"), mgr.GetClient(), &expinfrav1.ROSACluster{})), predicates.ClusterUnpaused(log.GetLogger()), ); err != nil { @@ -144,8 +144,8 @@ func (r *ROSAClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M // Add a watch for ROSAControlPlane if err = controller.Watch( - &source.Kind{Type: &rosacontrolplanev1.ROSAControlPlane{}}, - handler.EnqueueRequestsFromMapFunc(r.rosaControlPlaneToManagedCluster(ctx, log)), + source.Kind(mgr.GetCache(), &rosacontrolplanev1.ROSAControlPlane{}), + handler.EnqueueRequestsFromMapFunc(r.rosaControlPlaneToManagedCluster(log)), ); err != nil { return fmt.Errorf("failed adding watch on ROSAControlPlane: %w", err) } @@ -153,8 +153,8 @@ func (r *ROSAClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M return nil } -func (r *ROSAClusterReconciler) rosaControlPlaneToManagedCluster(ctx context.Context, log *logger.Logger) handler.MapFunc { - return func(o client.Object) []ctrl.Request { +func (r *ROSAClusterReconciler) rosaControlPlaneToManagedCluster(log *logger.Logger) handler.MapFunc { + return func(ctx context.Context, o client.Object) []ctrl.Request { ROSAControlPlane, ok := o.(*rosacontrolplanev1.ROSAControlPlane) if !ok { log.Error(errors.Errorf("expected an ROSAControlPlane, got %T instead", o), "failed to map ROSAControlPlane") diff --git a/controlplane/rosa/controllers/rosacontrolplane_controller.go b/controlplane/rosa/controllers/rosacontrolplane_controller.go index ed80c1dcfa..d18c5baf93 100644 --- a/controlplane/rosa/controllers/rosacontrolplane_controller.go +++ b/controlplane/rosa/controllers/rosacontrolplane_controller.go @@ -76,7 +76,7 @@ func (r *ROSAControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr c } if err = c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, rosaControlPlane.GroupVersionKind(), mgr.GetClient(), &expinfrav1.ROSACluster{})), predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger()), ); err != nil { @@ -84,8 +84,8 @@ func (r *ROSAControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr c } if err = c.Watch( - &source.Kind{Type: &expinfrav1.ROSACluster{}}, - handler.EnqueueRequestsFromMapFunc(r.rosaClusterToROSAControlPlane(ctx, log)), + source.Kind(mgr.GetCache(), &expinfrav1.ROSACluster{}), + handler.EnqueueRequestsFromMapFunc(r.rosaClusterToROSAControlPlane(log)), ); err != nil { return fmt.Errorf("failed adding a watch for ROSACluster") } @@ -377,8 +377,8 @@ func (r *ROSAControlPlaneReconciler) reconcileDelete(_ context.Context, rosaScop return ctrl.Result{}, nil } -func (r *ROSAControlPlaneReconciler) rosaClusterToROSAControlPlane(ctx context.Context, log *logger.Logger) handler.MapFunc { - return func(o client.Object) []ctrl.Request { +func (r *ROSAControlPlaneReconciler) rosaClusterToROSAControlPlane(log *logger.Logger) handler.MapFunc { + return func(ctx context.Context, o client.Object) []ctrl.Request { rosaCluster, ok := o.(*expinfrav1.ROSACluster) if !ok { log.Error(fmt.Errorf("expected a ROSACluster but got a %T", o), "Expected ROSACluster")