tenant

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectReferenceTenantKind = "Tenant"
)

Variables

This section is empty.

Functions

func AddNamespaceNameLabels

func AddNamespaceNameLabels(labels map[string]string, ns *corev1.Namespace)

func AddTenantNameLabel

func AddTenantNameLabel(labels map[string]string, tnt *capsulev1beta2.Tenant)

func BuildInstanceMetadataForNamespace

func BuildInstanceMetadataForNamespace(ns *corev1.Namespace, tnt *capsulev1beta2.Tenant) (labels map[string]string, annotations map[string]string)

func BuildNamespaceAnnotationsForTenant

func BuildNamespaceAnnotationsForTenant(tnt *capsulev1beta2.Tenant) map[string]string

func BuildNamespaceLabelsForTenant

func BuildNamespaceLabelsForTenant(tnt *capsulev1beta2.Tenant) map[string]string

func BuildNamespaceMetadataForTenant

func BuildNamespaceMetadataForTenant(ns *corev1.Namespace, tnt *capsulev1beta2.Tenant) (labels map[string]string, annotations map[string]string, err error)

func BuildNamespaceRuleBodyStatus

func BuildNamespaceRuleBodyStatus(
	ctx context.Context,
	c client.Reader,
	ns *corev1.Namespace,
	tnt *capsulev1beta2.Tenant,
) (*api.NamespaceRuleBodyNamespace, error)

BuildNamespaceRuleBodyForNamespace returns the aggregated rule body that applies to `ns`. - Rules with nil NamespaceSelector match all namespaces. - Matching rules are combined in the order they appear in tnt.Spec.Rules (important for "later wins" semantics).

func CollectPromotions

func CollectPromotions(
	ctx context.Context,
	c client.Client,
	tnt *capsulev1beta2.Tenant,
	cfg configuration.Configuration,
) (promotions rbac.PromotionStatusListSpec, err error)

func CollectTenantNamespaceByLabel

func CollectTenantNamespaceByLabel(
	ctx context.Context,
	c client.Client,
	tnt capsulev1beta2.Tenant,
	additionalSelector *metav1.LabelSelector,
) (namespaces []corev1.Namespace, err error)

func FastContextForTenantAndNamespace

func FastContextForTenantAndNamespace(tnt *capsulev1beta2.Tenant, ns *corev1.Namespace) map[string]string

TemplateForTenantAndNamespace applies templatingto the provided string.

func GetManagedRuleStatus

func GetManagedRuleStatus(
	ctx context.Context,
	c client.Reader,
	ns *corev1.Namespace,
) (*capsulev1beta2.RuleStatus, error)

func GetOwnersWithKinds

func GetOwnersWithKinds(tenant *capsulev1beta2.Tenant) (owners []string)

func GetTenantByLabels

func GetTenantByLabels(
	ctx context.Context,
	c client.Reader,
	ns *corev1.Namespace,
) (*capsulev1beta2.Tenant, error)

getTenantByLabels returns tenant from labels.

func GetTenantByNamespace

func GetTenantByNamespace(
	ctx context.Context,
	r client.Reader,
	namespace string,
) (*capsulev1beta2.Tenant, error)

func GetTenantByOwnerreferences

func GetTenantByOwnerreferences(
	ctx context.Context,
	c client.Reader,
	refs []metav1.OwnerReference,
) (tnt *capsulev1beta2.Tenant, err error)

getNamespaceTenant returns namespace owner tenant.

func GetTenantByUserInfo

func GetTenantByUserInfo(
	ctx context.Context,
	c client.Client,
	cfg configuration.Configuration,
	ns *corev1.Namespace,
	user users.AdmissionUser,
) (sortedTenants, error)

func GetTenantNameByNamespace

func GetTenantNameByNamespace(
	ctx context.Context,
	c client.Reader,
	namespace string,
) (tnt string, err error)

func GetTenantNameByOwnerreferences

func GetTenantNameByOwnerreferences(
	refs []metav1.OwnerReference,
) (string, bool)

func GetTenantNameByStatusNamespace

func GetTenantNameByStatusNamespace(
	ctx context.Context,
	c client.Client,
	namespace string,
) (string, error)

func HasCustomResourceQuotaAnnotation

func HasCustomResourceQuotaAnnotation(tenant *capsulev1beta2.Tenant) bool

func HasTenantOwnership

func HasTenantOwnership(ns *corev1.Namespace) bool

func HasTenantReference

func HasTenantReference(ns *corev1.Namespace) bool

func IsNamespaceInTenant

func IsNamespaceInTenant(
	ctx context.Context,
	c client.Client,
	namespace string,
) (bool, error)

func IsTenantOwnerReference

func IsTenantOwnerReference(or metav1.OwnerReference) bool

func IsTenantOwnerReferenceForTenant

func IsTenantOwnerReferenceForTenant(or metav1.OwnerReference, tnt *capsulev1beta2.Tenant) bool

func NamespaceIsPendingPodTerminating

func NamespaceIsPendingPodTerminating(
	ctx context.Context,
	c client.Reader,
	ns *corev1.Namespace,
) (pending bool, err error)

func NamespaceIsPendingUnmanagedTerminationByStatus

func NamespaceIsPendingUnmanagedTerminationByStatus(ctx context.Context, c client.Reader, ns *corev1.Namespace) (bool, error)

func NamespacedCascadingCleanup

func NamespacedCascadingCleanup(
	ctx context.Context,
	c client.Reader,
	disco discovery.DiscoveryInterface,
	resourceCache NamespacedResourceCache,
	dyn dynamic.Interface,
	ns *corev1.Namespace,
) (cleaned bool, err error)

First deletes (remove finalizers and deleted) all resources which are not managed by capsule Once fulfilled, remove all managed resources.

func NewTenantContext

func NewTenantContext(tnt *capsulev1beta2.Tenant, scheme *runtime.Scheme, opts sanitize.SanitizeOptions) (map[string]any, error)

NewTenantContext returns the context for the tenant.

func ResolveNamespaceTenant

func ResolveNamespaceTenant(
	ctx context.Context,
	reader client.Reader,
	ns *corev1.Namespace,
) (*capsulev1beta2.Tenant, error)

func TenanLabelValue

func TenanLabelValue(ns *corev1.Namespace) string

func TenantByStatusNamespace

func TenantByStatusNamespace(
	ctx context.Context,
	c client.Client,
	namespace string,
) (*capsulev1beta2.Tenant, error)

func TenantOwnerReferenceName

func TenantOwnerReferenceName(ns *corev1.Namespace) string

func TenantOwnerReferences

func TenantOwnerReferences(ns *corev1.Namespace) []metav1.OwnerReference

func TenantOwnershipChanged

func TenantOwnershipChanged(oldNs, newNs *corev1.Namespace) bool

Types

type NamespacedResourceCache

type NamespacedResourceCache interface {
	Get(disco discovery.DiscoveryInterface) ([]schema.GroupVersionResource, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL