mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-25 16:07:24 +00:00
feat(tenant): add dedicated tenantowner crd (#1764)
Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user