feat(tenant): add dedicated tenantowner crd (#1764)

Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
This commit is contained in:
Oliver Bähler
2025-12-02 15:21:46 +01:00
committed by GitHub
parent beb1cd3de4
commit d812a0c722
105 changed files with 2703 additions and 543 deletions
+22 -2
View File
@@ -21,13 +21,33 @@ func IsTenantOwner(
ctx context.Context,
c client.Client,
cfg configuration.Configuration,
tenant *capsulev1beta2.Tenant,
tnt *capsulev1beta2.Tenant,
userInfo authenticationv1.UserInfo,
) (bool, error) {
if isOwner := tenant.Spec.Owners.IsOwner(userInfo.Username, userInfo.Groups); isOwner {
if isOwner := tnt.Spec.Owners.IsOwner(userInfo.Username, userInfo.Groups); isOwner {
return true, nil
}
return IsCommonOwner(ctx, c, cfg, tnt, userInfo)
}
func IsTenantOwnerByStatus(
ctx context.Context,
c client.Client,
cfg configuration.Configuration,
tnt *capsulev1beta2.Tenant,
userInfo authenticationv1.UserInfo,
) bool {
return tnt.Status.Owners.IsOwner(userInfo.Username, userInfo.Groups)
}
func IsCommonOwner(
ctx context.Context,
c client.Client,
cfg configuration.Configuration,
tnt *capsulev1beta2.Tenant,
userInfo authenticationv1.UserInfo,
) (bool, error) {
// Administrators are always Owners
if cfg.Administrators().IsPresent(userInfo.Username, userInfo.Groups) {
return true, nil
+1 -1
View File
@@ -34,7 +34,7 @@ func ResolveServiceAccountActor(
sa := &corev1.ServiceAccount{}
if err = c.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, sa); err != nil {
if apierrors.IsNotFound(err) {
return tnt, err
return nil, nil
}
return tnt, err