feat: add rolebindings to rules api (#2032)

* feat: add rolebindings to rules api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add rolebindings to rules api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add rolebindings to rules api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add rolebindings to rules api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add rolebindings to rules api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: implement review

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

---------

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
This commit is contained in:
Oliver Bähler
2026-07-15 10:35:36 +02:00
committed by GitHub
parent 30e4f9d3e8
commit 9ee5468f47
14 changed files with 487 additions and 41 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ import (
type AdditionalRoleBindingsSpec struct {
ClusterRoleName string `json:"clusterRoleName"`
// kubebuilder:validation:Minimum=1
// +kubebuilder:validation:MinItems=1
Subjects []rbacv1.Subject `json:"subjects"`
// Additional Labels for the synchronized rolebindings
Labels map[string]string `json:"labels,omitempty"`
+5
View File
@@ -5,10 +5,15 @@ package rules
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/projectcapsule/capsule/pkg/api/rbac"
)
// +kubebuilder:object:generate=true
type NamespaceRulePermissionBody struct {
// Bindings defines additional RoleBindings for namespaces selected by this rule.
Bindings []rbac.AdditionalRoleBindingsSpec `json:"bindings,omitempty"`
// Define Promotion Rules which distributed additional ClusterRoles across the Tenant
// for promoted ServiceAccounts.
Promotions []*NamespaceRulePromotionRule `json:"promotions,omitempty"`
+8
View File
@@ -8,6 +8,7 @@
package rules
import (
"github.com/projectcapsule/capsule/pkg/api/rbac"
"github.com/projectcapsule/capsule/pkg/api/runtime"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -212,6 +213,13 @@ func (in *NamespaceRuleEnforceWorkloadsBody) DeepCopy() *NamespaceRuleEnforceWor
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NamespaceRulePermissionBody) DeepCopyInto(out *NamespaceRulePermissionBody) {
*out = *in
if in.Bindings != nil {
in, out := &in.Bindings, &out.Bindings
*out = make([]rbac.AdditionalRoleBindingsSpec, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Promotions != nil {
in, out := &in.Promotions, &out.Promotions
*out = make([]*NamespaceRulePromotionRule, len(*in))