Skip to content

Commit e79a487

Browse files
authored
remove label in nss-runtime-managed-role (#159)
1 parent 93cb8fd commit e79a487

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

controllers/namespacescope_controller.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ func (r *NamespaceScopeReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
132132
if rolesList, _ := r.GetRolesFromNamespace(namespaceMember); len(rolesList) != 0 {
133133
var summarizedRules []rbacv1.PolicyRule
134134
for _, role := range rolesList {
135-
if role.Name != constant.NamespaceScopeManagedPrefix+instance.Namespace &&
136-
role.Name != constant.NamespaceScopeRuntimePrefix+instance.Namespace {
135+
if role.Name != constant.NamespaceScopeManagedPrefix+instance.Namespace {
137136
summarizedRules = append(summarizedRules, role.Rules...)
138137
}
139138
}
@@ -405,13 +404,9 @@ func (r *NamespaceScopeReconciler) generateRBACForNSS(instance *operatorv1.Names
405404
}
406405

407406
func (r *NamespaceScopeReconciler) generateRuntimeRoleForNSS(instance *operatorv1.NamespaceScope, summarizedRules []rbacv1.PolicyRule, fromNs, toNs string) error {
408-
labels := map[string]string{
409-
"namespace-scope-configmap": instance.Namespace + "-" + instance.Spec.ConfigmapName,
410-
}
411-
412-
if err := r.createRuntimeRoleForNSS(labels, summarizedRules, fromNs, toNs); err != nil {
407+
if err := r.createRuntimeRoleForNSS(summarizedRules, fromNs, toNs); err != nil {
413408
if errors.IsAlreadyExists(err) {
414-
if err := r.updateRuntimeRoleForNSS(labels, summarizedRules, fromNs, toNs); err != nil {
409+
if err := r.updateRuntimeRoleForNSS(summarizedRules, fromNs, toNs); err != nil {
415410
return err
416411
}
417412
return nil
@@ -425,14 +420,13 @@ func (r *NamespaceScopeReconciler) generateRuntimeRoleForNSS(instance *operatorv
425420
return nil
426421
}
427422

428-
func (r *NamespaceScopeReconciler) createRuntimeRoleForNSS(labels map[string]string, summarizedRules []rbacv1.PolicyRule, fromNs, toNs string) error {
423+
func (r *NamespaceScopeReconciler) createRuntimeRoleForNSS(summarizedRules []rbacv1.PolicyRule, fromNs, toNs string) error {
429424
name := constant.NamespaceScopeRuntimePrefix + fromNs
430425
namespace := toNs
431426
role := &rbacv1.Role{
432427
ObjectMeta: metav1.ObjectMeta{
433428
Name: name,
434429
Namespace: namespace,
435-
Labels: labels,
436430
},
437431
Rules: summarizedRules,
438432
}
@@ -448,15 +442,14 @@ func (r *NamespaceScopeReconciler) createRuntimeRoleForNSS(labels map[string]str
448442
return nil
449443
}
450444

451-
func (r *NamespaceScopeReconciler) updateRuntimeRoleForNSS(labels map[string]string, summarizedRules []rbacv1.PolicyRule, fromNs, toNs string) error {
445+
func (r *NamespaceScopeReconciler) updateRuntimeRoleForNSS(summarizedRules []rbacv1.PolicyRule, fromNs, toNs string) error {
452446
name := constant.NamespaceScopeRuntimePrefix + fromNs
453447
namespace := toNs
454448

455449
role := &rbacv1.Role{
456450
ObjectMeta: metav1.ObjectMeta{
457451
Name: name,
458452
Namespace: namespace,
459-
Labels: labels,
460453
},
461454
Rules: summarizedRules,
462455
}

0 commit comments

Comments
 (0)