Skip to content

Commit

Permalink
fix: nil pointer dereference for ExternalClusterReference
Browse files Browse the repository at this point in the history
When running the Kamaji Control Plane provider with the
ExternalClusterReference feature gate enabled, a nil pointer dereference
was occurring due to a missing check.

Signed-off-by: Dario Tranchitella <[email protected]>
  • Loading branch information
prometherion committed Oct 23, 2024
1 parent d929969 commit 3013952
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/externalclusterreference_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,14 @@ func (r *ExternalClusterReferenceReconciler) SetupWithManager(mgr ctrl.Manager)
return ctrl.NewControllerManagedBy(mgr).
For(&corev1.Secret{}).
Watches(&v1alpha1.KamajiControlPlane{}, handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, object client.Object) []reconcile.Request {
kcp := object.(*v1alpha1.KamajiControlPlane) //nolint:forcetypeassert
if kcp.Spec.Deployment.ExternalClusterReference == nil {
return nil
}

var requests []reconcile.Request

for _, secret := range r.getSecretFromKamajiControlPlaneReferences(ctx, object.(*v1alpha1.KamajiControlPlane)) { //nolint:forcetypeassert
for _, secret := range r.getSecretFromKamajiControlPlaneReferences(ctx, kcp) {
requests = append(requests, reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: secret.Namespace,
Expand Down

0 comments on commit 3013952

Please sign in to comment.