common

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

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)

View Source
var HubConfig *rest.Config

KubeClient a k8s client used for k8s native resources

View Source
var KubeConfig *rest.Config

KubeConfig is the given kubeconfig at startup

Functions

func CreateRecorder

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

CreateRecorder return recorder

func DeduplicateItems

func DeduplicateItems(included []string, excluded []string) (res []string)

DeduplicateItems does the dedup

func ExtractNamespaceLabel

func ExtractNamespaceLabel(instance *policyv1.ConfigurationPolicy) string

ExtractNamespaceLabel to find out the cluster-namespace from the label

func FindPattern

func FindPattern(pattern string, list []string) (result []string)

FindPattern finds patterns

func GetAllNamespaces

func GetAllNamespaces() (list []string, err error)

GetAllNamespaces gets the list of all namespaces from k8s

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the namespace the operator should be running in.

func GetSelectedNamespaces

func GetSelectedNamespaces(included, excluded, allNamespaces []string) []string

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 IfMatch

func IfMatch(name string, included, excluded []string) bool

IfMatch check matches

func Initialize

func Initialize(kClient kubernetes.Interface, cfg *rest.Config)

Initialize to initialize some controller variables

func LoadHubConfig

func LoadHubConfig(namespace string, secretname string) (*rest.Config, error)

func MatchNames

func MatchNames(all, included, excluded []string) []string

MatchNames matches names

func Round

func Round(num float64) int

Round rounds the value

func ToFixed

func ToFixed(num float64, precision int) float64

ToFixed returns a float with a certain precision

Types

type RunModeType

type RunModeType string
const (
	ForceRunModeEnv             = "OSDK_FORCE_RUN_MODE"
	LocalRunMode    RunModeType = "local"
	ClusterRunMode  RunModeType = "cluster"
)

type SyncedPolicyMap

type SyncedPolicyMap struct {
	PolicyMap map[string]*policiesv1.ConfigurationPolicy
	// Mx for making the map thread safe
	Mx sync.RWMutex
}

SyncedPolicyMap a thread safe map

func (*SyncedPolicyMap) AddObject

func (spm *SyncedPolicyMap) AddObject(key string, plc *policiesv1.ConfigurationPolicy)

AddObject safely add to map

func (*SyncedPolicyMap) GetObject

func (spm *SyncedPolicyMap) GetObject(key string) (value *policiesv1.ConfigurationPolicy, found bool)

GetObject used for fetching objects from the synced map

func (*SyncedPolicyMap) RemoveObject

func (spm *SyncedPolicyMap) RemoveObject(key string)

RemoveObject safely remove from map

Jump to

Keyboard shortcuts

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