Skip to content

Commit 52402f4

Browse files
committed
[controller] Patching the (Cluster)RoleBinding to match Kuadrant NS
* It needs some DRY up * There's no easy way, since obj is type interface when multiple case types
1 parent a49a69c commit 52402f4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

controllers/kuadrant_controller.go

+20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
iopv1alpha1 "istio.io/istio/operator/pkg/apis/istio/v1alpha1"
2929
appsv1 "k8s.io/api/apps/v1"
3030
v1 "k8s.io/api/core/v1"
31+
rbacv1 "k8s.io/api/rbac/v1"
3132
apierrors "k8s.io/apimachinery/pkg/api/errors"
3233
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3334
"k8s.io/apimachinery/pkg/runtime"
@@ -406,6 +407,25 @@ func (r *KuadrantReconciler) createOnlyInKuadrantNSCb(ctx context.Context, kObj
406407
v1.EnvVar{Name: envLimitadorName, Value: limitadorName},
407408
)
408409
newObj = obj
410+
// TODO: DRY the following 2 case switches
411+
case *rbacv1.RoleBinding:
412+
if obj.Name == "kuadrant-leader-election-rolebinding" {
413+
for i, subject := range obj.Subjects {
414+
if subject.Name == "kuadrant-controller-manager" {
415+
obj.Subjects[i].Namespace = kObj.Namespace
416+
}
417+
}
418+
}
419+
newObj = obj
420+
case *rbacv1.ClusterRoleBinding:
421+
if obj.Name == "kuadrant-manager-rolebinding" {
422+
for i, subject := range obj.Subjects {
423+
if subject.Name == "kuadrant-controller-manager" {
424+
obj.Subjects[i].Namespace = kObj.Namespace
425+
}
426+
}
427+
}
428+
newObj = obj
409429
default:
410430
}
411431
newObjCloned := newObj.DeepCopyObject()

0 commit comments

Comments
 (0)