common

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

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"
)
View Source
const UninstallingAnnotation string = "policy.open-cluster-management.io/uninstalling"

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 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

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 GetSelectedNamespaces

func GetSelectedNamespaces(client kubernetes.Interface, selector policyv1.Target) ([]string, error)

GetSelectedNamespaces returns the list of filtered namespaces according to the policy namespace selector.

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 RunModeType

type RunModeType string

Jump to

Keyboard shortcuts

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