Skip to content

Commit

Permalink
adapt code after CAPI bump to v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
muraee committed Oct 5, 2023
1 parent ecc99a2 commit 7f4d3ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions controllers/rosacluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -144,17 +144,17 @@ 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)
}

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")
Expand Down
10 changes: 5 additions & 5 deletions controlplane/rosa/controllers/rosacontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ 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 {
return fmt.Errorf("failed adding a watch for ready clusters: %w", err)
}

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")
}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 7f4d3ef

Please sign in to comment.