Documentation ¶
Index ¶
- Constants
- Variables
- func CreateRecorder(kubeClient kubernetes.Interface, componentName string) (record.EventRecorder, error)
- func GetAllNamespaces(client kubernetes.Interface, labelSelector metav1.LabelSelector) ([]string, error)
- func GetOperatorName() (string, error)
- func GetOperatorNamespace() (string, error)
- func GetOperatorNamespacedName() (types.NamespacedName, error)
- func GetSelectedNamespaces(client kubernetes.Interface, selector policyv1.Target) ([]string, error)
- func GetWatchNamespace() (string, error)
- func Matches(namespaces []string, includeList []policyv1.NonEmptyString, ...) ([]string, error)
- type NamespaceSelectorReconciler
- func (r *NamespaceSelectorReconciler) Get(name string, t policyv1.Target) ([]string, error)
- func (r *NamespaceSelectorReconciler) HasUpdate(name string) bool
- func (r *NamespaceSelectorReconciler) Reconcile(ctx context.Context, _ ctrl.Request) (ctrl.Result, error)
- func (r *NamespaceSelectorReconciler) SetupWithManager(mgr ctrl.Manager) error
- func (r *NamespaceSelectorReconciler) Stop(name string)
- type RunModeType
- type SelectorReconciler
Constants ¶
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" )
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 ¶
var ErrNoNamespace = fmt.Errorf("namespace not found for current environment")
ErrNoNamespace indicates that a namespace could not be found for the current environment
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 GetAllNamespaces ¶
func GetAllNamespaces(client kubernetes.Interface, labelSelector metav1.LabelSelector) ([]string, error)
GetAllNamespaces gets the list of all namespaces from k8s that matches the input label selector.
func GetOperatorName ¶ added in v0.10.0
GetOperatorName returns the operator name
func GetOperatorNamespace ¶
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 GetSelectedNamespaces ¶
GetSelectedNamespaces returns the list of filtered namespaces according to the policy namespace selector.
func GetWatchNamespace ¶
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 { Client client.Client // contains filtered or unexported fields }
func (*NamespaceSelectorReconciler) Get ¶ added in v0.12.0
Get returns the items matching the given Target for the given policy. If no selection for that policy 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(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
func (r *NamespaceSelectorReconciler) Reconcile(ctx context.Context, _ ctrl.Request) (ctrl.Result, error)
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(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 name. If no selection for that // name and Target has been calculated, it will be calculated now. Otherwise, a cached value // may be used. Get(string, policyv1.Target) ([]string, error) // HasUpdate indicates when the cached selection for this name has been changed since the last // time that Get was called for that name. HasUpdate(string) bool // Stop tells the SelectorReconciler to stop updating the cached selection for the name. Stop(string) }
SelectorReconciler keeps a cache of NamespaceSelector results, which it should update when namespaces are created, deleted, or re-labeled.