utils

package
v1.45.0-0.dev Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const CloudAuthConfig = "cloud-auth-config"

CloudAuthConfig is the name of the ConfigMap holding cloud authentication configuration (e.g. the tenantID) for a single-tenant cloud management cluster backed by internal Elasticsearch.

Variables

This section is empty.

Functions

func DexEnabled

func DexEnabled(authentication *operatorv1.Authentication) bool

func EnqueueAllTenants

func EnqueueAllTenants(c client.Client) handler.EventHandler

func GetApplicationLayer

func GetApplicationLayer(ctx context.Context, c client.Client) (*operatorv1.ApplicationLayer, error)

Return the AplicationLayer CR if present. No error is returned if it was not found.

func GetAuthentication

func GetAuthentication(ctx context.Context, cli client.Client) (*operatorv1.Authentication, error)

GetAuthentication finds the authentication CR in your cluster.

func GetCloudConfig

func GetCloudConfig(ctx context.Context, cli client.Client) (*cloudconfig.CloudConfig, error)

GetCloudConfig retrieves the config map containing the configuration values needed to set up communications with external Elasticsearch and Kibana, such as the externalESDomain and externalKibanaDomain.

func GetIDPSecret

func GetIDPSecret(ctx context.Context, client client.Client, authentication *operatorv1.Authentication) (*corev1.Secret, error)

GetIDPSecret retrieves the Secret containing sensitive information for the configuration IdP specified in the given operatorv1.Authentication CR.

func GetKeyValidatorConfig

func GetKeyValidatorConfig(ctx context.Context, cli client.Client, authenticationCR *operatorv1.Authentication, clusterDomain string, addTenancyClaim bool) (rauth.KeyValidatorConfig, error)

GetKeyValidatorConfig uses the operatorv1.Authentication CR given to create the KeyValidatorConfig. This may be either a DexKeyValidatorConfig or a tigerakvc.KeyValidatorConfig.

addTenancyClaim must only be set for Calico Cloud single-tenant management clusters; when true the KeyValidatorConfig is configured to require the cloud tenant claim (read from the cloud-auth-config ConfigMap). Regular Calico/Calico Enterprise callers pass false, leaving behavior unchanged.

func GetLogCollector

func GetLogCollector(ctx context.Context, cli client.Client) (*operatorv1.LogCollector, error)

func GetManagementCluster

func GetManagementCluster(ctx context.Context, c client.Client) (*operatorv1.ManagementCluster, error)

Return the ManagementCluster CR if present. No error is returned if it was not found.

func GetManager

func GetManager(ctx context.Context, cli client.Client, multiTenant bool, ns string) (*operatorv1.Manager, error)

GetManager returns the Manager CR, or nil if it is not found. When multiTenant is true the tenant-scoped instance is read from ns; otherwise the cluster-scoped instance is read and ns is ignored. A NoMatchError (the Manager CRD is not registered) is returned to the caller rather than treated as not-found: absence of the CRD is distinct from the user not having created a Manager, and the caller decides how to handle it.

func GetNonClusterHost

func GetNonClusterHost(ctx context.Context, cli client.Client) (*operatorv1.NonClusterHost, error)

GetNonClusterHost finds the NonClusterHost CR in your cluster.

func GetPacketCaptureAPI

func GetPacketCaptureAPI(ctx context.Context, cli client.Client) (*operatorv1.PacketCaptureAPI, error)

GetPacketCapture finds the PacketCapture CR in your cluster.

func GetSecretNameAndRequiredFields

func GetSecretNameAndRequiredFields(authentication *operatorv1.Authentication) (string, []string)

func GetSecretOrProviderClass

func GetSecretOrProviderClass(ctx context.Context, client client.Client, authentication *operatorv1.Authentication) (*csisecret.SecretProviderClass, *corev1.Secret, error)

func GetSecretProviderClass

func GetSecretProviderClass(ctx context.Context, client client.Client, authentication *operatorv1.Authentication) (*csisecret.SecretProviderClass, error)

func GetTenant

func GetTenant(ctx context.Context, mt bool, cli client.Client, ns string) (*operatorv1.Tenant, string, error)

GetTenant returns the Tenant instance in the given namespace.

func GetTenantFromCloudAuthConfig

func GetTenantFromCloudAuthConfig(ctx context.Context, cli client.Client) (*v1.Tenant, error)

func HelperNamespaces

func HelperNamespaces(ctx context.Context, cli client.Client, helper NamespaceHelper, include TenantFilter) ([]string, error)

HelperNamespaces is TenantNamespaces for a component, returning the install namespace when the helper is single-tenant.

func LogStorageExists

func LogStorageExists(ctx context.Context, cli client.Client) (bool, error)

func ManagedCalicoOnly

func ManagedCalicoOnly(t *operatorv1.Tenant) bool

ManagedCalicoOnly is a TenantFilter that matches tenants who manage Calico OSS clusters.

func ManagedEnterpriseOnly

func ManagedEnterpriseOnly(t *operatorv1.Tenant) bool

ManagedEnterpriseOnly is a TenantFilter that matches tenants who manage Calico Enterprise clusters.

func TenantFromCloudConfig

func TenantFromCloudConfig(c *cloudconfig.CloudConfig) *v1.Tenant

ToTenant converts the given CloudConfig structure to a Tenant object. This allows controllers that have been converted to support multi-tenancy to still leverage the single-tenant CloudConfig structure using the same code path as in multi-tenancy.

func TenantNamespaces

func TenantNamespaces(ctx context.Context, cli client.Client, include TenantFilter) ([]string, error)

TenantNamespaces returns all namespaces that contain a tenant. include is an optional filter function that returns true if the tenant should be included, false otherwise.

Types

type NamespaceHelper

type NamespaceHelper interface {
	// InstallNamespace returns the namespace that components will be installed into.
	// for single-tenant clusters, this is generally a well-known namespace of the form tigera-*.
	// For multi-tenant clusters, this is the tenant's namespace.
	InstallNamespace() string

	// TruthNamespace returns the namespace to use as the source of truth for storing data.
	// For single-tenant installs, this is the tigera-operator namespace.
	// For multi-tenant installs, this is tenant's namespace.
	TruthNamespace() string

	// Returns whether or not this is a multi-tenant helper.
	MultiTenant() bool
}

func NewNamespaceHelper

func NewNamespaceHelper(mt bool, singleTenantNS, multiTenantNS string) NamespaceHelper

func NewSingleTenantNamespaceHelper

func NewSingleTenantNamespaceHelper(ns string) NamespaceHelper

type TenantFilter

type TenantFilter func(*operatorv1.Tenant) bool

TenantFilter is a function that accepts a tenant and returns true if the Tenant should be included in the query, and false otherwise.

Jump to

Keyboard shortcuts

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