Skip to content

Commit 722d8cc

Browse files
committed
use source.Kind generics
1 parent 011cb32 commit 722d8cc

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

bootstrap/eks/controllers/eksconfig_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ func (r *EKSConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
313313
}
314314

315315
err = c.Watch(
316-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
317-
handler.EnqueueRequestsFromMapFunc((r.ClusterToEKSConfigs)),
318-
predicates.ClusterUnpausedAndInfrastructureReady(logger.FromContext(ctx).GetLogger()),
316+
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
317+
handler.EnqueueRequestsFromMapFunc((r.ClusterToEKSConfigs)),
318+
predicates.ClusterUnpausedAndInfrastructureReady(logger.FromContext(ctx).GetLogger())),
319319
)
320320
if err != nil {
321321
return errors.Wrap(err, "failed adding watch for Clusters to controller manager")

controllers/awscluster_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,10 @@ func (r *AWSClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
413413
}
414414

415415
return controller.Watch(
416-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
417-
handler.EnqueueRequestsFromMapFunc(r.requeueAWSClusterForUnpausedCluster(ctx, log)),
418-
predicates.ClusterUnpaused(log.GetLogger()),
419-
)
416+
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
417+
handler.EnqueueRequestsFromMapFunc(r.requeueAWSClusterForUnpausedCluster(ctx, log)),
418+
predicates.ClusterUnpaused(log.GetLogger()),
419+
))
420420
}
421421

422422
func (r *AWSClusterReconciler) requeueAWSClusterForUnpausedCluster(_ context.Context, log logger.Wrapper) handler.MapFunc {

controllers/awsmachine_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ func (r *AWSMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
292292

293293
requeueAWSMachinesForUnpausedCluster := r.requeueAWSMachinesForUnpausedCluster(log)
294294
return controller.Watch(
295-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
296-
handler.EnqueueRequestsFromMapFunc(requeueAWSMachinesForUnpausedCluster),
297-
predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger()),
295+
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
296+
handler.EnqueueRequestsFromMapFunc(requeueAWSMachinesForUnpausedCluster),
297+
predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger())),
298298
)
299299
}
300300

controllers/awsmanagedcluster_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@ func (r *AWSManagedClusterReconciler) SetupWithManager(ctx context.Context, mgr
134134

135135
// Add a watch for clusterv1.Cluster unpaise
136136
if err = controller.Watch(
137-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
138-
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("AWSManagedCluster"), mgr.GetClient(), &infrav1.AWSManagedCluster{})),
139-
predicates.ClusterUnpaused(log.GetLogger()),
137+
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
138+
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("AWSManagedCluster"), mgr.GetClient(), &infrav1.AWSManagedCluster{})),
139+
predicates.ClusterUnpaused(log.GetLogger())),
140140
); err != nil {
141141
return fmt.Errorf("failed adding a watch for ready clusters: %w", err)
142142
}
143143

144144
// Add a watch for AWSManagedControlPlane
145145
if err = controller.Watch(
146-
source.Kind(mgr.GetCache(), &ekscontrolplanev1.AWSManagedControlPlane{}),
147-
handler.EnqueueRequestsFromMapFunc(r.managedControlPlaneToManagedCluster(ctx, log)),
146+
source.Kind[client.Object](mgr.GetCache(), &ekscontrolplanev1.AWSManagedControlPlane{},
147+
handler.EnqueueRequestsFromMapFunc(r.managedControlPlaneToManagedCluster(ctx, log))),
148148
); err != nil {
149149
return fmt.Errorf("failed adding watch on AWSManagedControlPlane: %w", err)
150150
}

controllers/rosacluster_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,17 @@ func (r *ROSAClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
136136

137137
// Add a watch for clusterv1.Cluster unpaise
138138
if err = controller.Watch(
139-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
140-
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("ROSACluster"), mgr.GetClient(), &expinfrav1.ROSACluster{})),
141-
predicates.ClusterUnpaused(log.GetLogger()),
139+
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
140+
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("ROSACluster"), mgr.GetClient(), &expinfrav1.ROSACluster{})),
141+
predicates.ClusterUnpaused(log.GetLogger())),
142142
); err != nil {
143143
return fmt.Errorf("failed adding a watch for ready clusters: %w", err)
144144
}
145145

146146
// Add a watch for ROSAControlPlane
147147
if err = controller.Watch(
148-
source.Kind(mgr.GetCache(), &rosacontrolplanev1.ROSAControlPlane{}),
149-
handler.EnqueueRequestsFromMapFunc(r.rosaControlPlaneToManagedCluster(log)),
148+
source.Kind[client.Object](mgr.GetCache(), &rosacontrolplanev1.ROSAControlPlane{},
149+
handler.EnqueueRequestsFromMapFunc(r.rosaControlPlaneToManagedCluster(log))),
150150
); err != nil {
151151
return fmt.Errorf("failed adding watch on ROSAControlPlane: %w", err)
152152
}

controlplane/eks/controllers/awsmanagedcontrolplane_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,16 @@ func (r *AWSManagedControlPlaneReconciler) SetupWithManager(ctx context.Context,
177177
}
178178

179179
if err = c.Watch(
180-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
181-
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, awsManagedControlPlane.GroupVersionKind(), mgr.GetClient(), &ekscontrolplanev1.AWSManagedControlPlane{})),
182-
predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger()),
180+
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
181+
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, awsManagedControlPlane.GroupVersionKind(), mgr.GetClient(), &ekscontrolplanev1.AWSManagedControlPlane{})),
182+
predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger())),
183183
); err != nil {
184184
return fmt.Errorf("failed adding a watch for ready clusters: %w", err)
185185
}
186186

187187
if err = c.Watch(
188-
source.Kind(mgr.GetCache(), &infrav1.AWSManagedCluster{}),
189-
handler.EnqueueRequestsFromMapFunc(r.managedClusterToManagedControlPlane(ctx, log)),
188+
source.Kind[client.Object](mgr.GetCache(), &infrav1.AWSManagedCluster{},
189+
handler.EnqueueRequestsFromMapFunc(r.managedClusterToManagedControlPlane(ctx, log))),
190190
); err != nil {
191191
return fmt.Errorf("failed adding a watch for AWSManagedCluster")
192192
}

controlplane/rosa/controllers/rosacontrolplane_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ func (r *ROSAControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr c
104104
}
105105

106106
if err = c.Watch(
107-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
108-
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, rosaControlPlane.GroupVersionKind(), mgr.GetClient(), &expinfrav1.ROSACluster{})),
109-
predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger()),
107+
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
108+
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, rosaControlPlane.GroupVersionKind(), mgr.GetClient(), &expinfrav1.ROSACluster{})),
109+
predicates.ClusterUnpausedAndInfrastructureReady(log.GetLogger())),
110110
); err != nil {
111111
return fmt.Errorf("failed adding a watch for ready clusters: %w", err)
112112
}
113113

114114
if err = c.Watch(
115-
source.Kind(mgr.GetCache(), &expinfrav1.ROSACluster{}),
116-
handler.EnqueueRequestsFromMapFunc(r.rosaClusterToROSAControlPlane(log)),
115+
source.Kind[client.Object](mgr.GetCache(), &expinfrav1.ROSACluster{},
116+
handler.EnqueueRequestsFromMapFunc(r.rosaClusterToROSAControlPlane(log))),
117117
); err != nil {
118118
return fmt.Errorf("failed adding a watch for ROSACluster")
119119
}

0 commit comments

Comments
 (0)