mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-23 14:36:54 +00:00
36 lines
822 B
Go
36 lines
822 B
Go
// Copyright 2020-2025 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package tenant
|
|
|
|
import (
|
|
"context"
|
|
|
|
authenticationv1 "k8s.io/api/authentication/v1"
|
|
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/configuration"
|
|
"github.com/projectcapsule/capsule/pkg/utils/users"
|
|
)
|
|
|
|
func NamespaceIsOwned(
|
|
ctx context.Context,
|
|
c client.Client,
|
|
cfg configuration.Configuration,
|
|
ns *corev1.Namespace,
|
|
tnt *capsulev1beta2.Tenant,
|
|
userInfo authenticationv1.UserInfo,
|
|
) bool {
|
|
for _, ownerRef := range ns.OwnerReferences {
|
|
if !IsTenantOwnerReferenceForTenant(ownerRef, tnt) {
|
|
continue
|
|
}
|
|
|
|
return users.IsTenantOwnerByStatus(ctx, c, cfg, tnt, userInfo)
|
|
}
|
|
|
|
return false
|
|
}
|