mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-22 05:57:02 +00:00
feat: upstream enterprise preview --------- Signed-off-by: Oliver Baehler <oliver@sudo-i.net> Co-authored-by: CorentinPtrl <pitrel.corentin@gmail.com>
35 lines
748 B
Go
35 lines
748 B
Go
// Copyright 2020-2026 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package tenant
|
|
|
|
import (
|
|
"context"
|
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
|
|
capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
|
|
"github.com/projectcapsule/capsule/pkg/runtime/configuration"
|
|
"github.com/projectcapsule/capsule/pkg/users"
|
|
)
|
|
|
|
func NamespaceIsOwned(
|
|
ctx context.Context,
|
|
c client.Reader,
|
|
cfg configuration.Configuration,
|
|
ns *corev1.Namespace,
|
|
tnt *capsulev1beta2.Tenant,
|
|
user users.AdmissionUser,
|
|
) bool {
|
|
for _, ownerRef := range ns.OwnerReferences {
|
|
if !IsTenantOwnerReferenceForTenant(ownerRef, tnt) {
|
|
continue
|
|
}
|
|
|
|
return users.IsTenantOwnerByStatus(tnt, user)
|
|
}
|
|
|
|
return false
|
|
}
|