common

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	UninstallingAnnotation string = "policy.open-cluster-management.io/uninstalling"
	PolicyDBIDAnnotation   string = "policy.open-cluster-management.io/policy-compliance-db-id"
	ParentDBIDAnnotation   string = "policy.open-cluster-management.io/parent-policy-compliance-db-id"
)
View Source
const (
	ForceRunModeEnv             = "OSDK_FORCE_RUN_MODE"
	LocalRunMode    RunModeType = "local"
	ClusterRunMode  RunModeType = "cluster"

	// OperatorNameEnvVar is the constant for env variable OPERATOR_NAME
	// which is the name of the current operator
	OperatorNameEnvVar = "OPERATOR_NAME"
)

Variables

View Source
var ErrNoNamespace = fmt.Errorf("namespace not found for current environment")

ErrNoNamespace indicates that a namespace could not be found for the current environment

View Source
var ErrRunLocal = fmt.Errorf("operator run mode forced to local")

ErrRunLocal indicates that the operator is set to run in local mode (this error is returned by functions that only work on operators running in cluster mode)

Functions

func CreateRecorder

func CreateRecorder(kubeClient kubernetes.Interface, componentName string) (record.EventRecorder, error)

CreateRecorder return recorder

func GetOperatorName added in v0.10.0

func GetOperatorName() (string, error)

GetOperatorName returns the operator name

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the namespace the operator should be running in.

func GetOperatorNamespacedName added in v0.10.0

func GetOperatorNamespacedName() (types.NamespacedName, error)

GetOperatorNamespacedName returns the name and namespace of the operator.

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the Namespace the operator should be watching for changes

func Matches added in v0.8.0

func Matches(
	namespaces []string,
	includeList []policyv1.NonEmptyString,
	excludeList []policyv1.NonEmptyString,
) ([]string, error)

Matches filters a slice of strings, and returns ones that match the selector

Types

type NamespaceSelectorReconciler added in v0.12.0

type NamespaceSelectorReconciler struct {
	// contains filtered or unexported fields
}

func NewNamespaceSelectorReconciler added in v0.15.0

func NewNamespaceSelectorReconciler(
	k8sClient client.Client, updateChannel chan<- event.GenericEvent,
) NamespaceSelectorReconciler

func (*NamespaceSelectorReconciler) Get added in v0.12.0

func (r *NamespaceSelectorReconciler) Get(objNS string, objName string, t policyv1.Target) ([]string, error)

Get returns the items matching the given Target for the given object. If there's no selection for that object, and Target has been calculated, it will be calculated now. Otherwise, a cached value may be used.

func (*NamespaceSelectorReconciler) HasUpdate added in v0.12.0

func (r *NamespaceSelectorReconciler) HasUpdate(namespace string, name string) bool

HasUpdate indicates when the cached selection for this policy has been changed since the last time that Get was called for that policy.

func (*NamespaceSelectorReconciler) Reconcile added in v0.12.0

Reconcile runs whenever a namespace on the target cluster is created, deleted, or has a change in labels. It updates the cached selections for NamespaceSelectors that it knows about.

func (*NamespaceSelectorReconciler) SetupWithManager added in v0.12.0

func (r *NamespaceSelectorReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*NamespaceSelectorReconciler) Stop added in v0.12.0

func (r *NamespaceSelectorReconciler) Stop(namespace string, name string)

Stop tells the SelectorReconciler to stop updating the cached selection for the name.

type RunModeType

type RunModeType string

type SelectorReconciler added in v0.12.0

type SelectorReconciler interface {
	// Get returns the items matching the given Target for the given object. If there's  no selection for that object,
	// and Target has been calculated, it will be calculated now. Otherwise, a cached value may be used.
	Get(objNS string, objName string, t policyv1.Target) ([]string, error)

	// HasUpdate indicates when the cached selection for this namespace and name has been changed since the last
	// time that Get was called for that name.
	HasUpdate(string, string) bool

	// Stop tells the SelectorReconciler to stop updating the cached selection for the namespace and name.
	Stop(string, string)
}

SelectorReconciler keeps a cache of NamespaceSelector results, which it should update when namespaces are created, deleted, or re-labeled.

Jump to

Keyboard shortcuts

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