utils

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ResourceHashAnnotationKey = "cassandra.datastax.com/resource-hash"
View Source
const (
	// WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE
	// which is the namespace where the watch activity happens.
	// this value is empty if the operator is running with clusterScope.
	WatchNamespaceEnvVar = "WATCH_NAMESPACE"
)

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 ForceRunModeEnv = "OSDK_FORCE_RUN_MODE"

ForceRunModeEnv indicates if the operator should be forced to run in either local or cluster mode (currently only used for local mode)

Functions

func AddHashAnnotation

func AddHashAnnotation(r Annotated)

func AppendValuesToStringArrayIfNotPresent

func AppendValuesToStringArrayIfNotPresent(a []string, values ...string) []string

func DeepHashObject added in v1.13.0

func DeepHashObject(hasher hash.Hash, objectToWrite interface{})

DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.

func ElementsMatch

func ElementsMatch(a interface{}, b interface{}) bool

func FilterNodesWithFn

func FilterNodesWithFn(nodes []*corev1.Node, fn func(*corev1.Node) bool) []*corev1.Node

func FilterNodesWithTaintKeyValueEffect

func FilterNodesWithTaintKeyValueEffect(nodes []*corev1.Node, taintKey, value string, effect corev1.TaintEffect) []*corev1.Node

func FilterPVCsWithFn

k8s PVC helpers

func FilterPodsWithAnnotationKey

func FilterPodsWithAnnotationKey(pods []*corev1.Pod, key string) []*corev1.Pod

func FilterPodsWithFn

func FilterPodsWithFn(pods []*corev1.Pod, fn func(*corev1.Pod) bool) []*corev1.Pod

func FilterPodsWithLabel

func FilterPodsWithLabel(pods []*corev1.Pod, label, value string) []*corev1.Pod

func FilterPodsWithNodeInNameSet

func FilterPodsWithNodeInNameSet(pods []*corev1.Pod, nameSet StringSet) []*corev1.Pod

func GenerateJKS

func GenerateJKS(ca *corev1.Secret, podname, dcname string) (jksblob []byte, err error)

func GetGVKsFromAddToScheme

func GetGVKsFromAddToScheme(addToSchemeFunc func(*runtime.Scheme) error) ([]schema.GroupVersionKind, error)

GetGVKsFromAddToScheme takes in the runtime scheme and filters out all generic apimachinery meta types. It returns just the GVK specific to this scheme.

func GetNewCAandKey

func GetNewCAandKey(leafdomain, namespace string) (keypem, certpem string, err error)

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the namespace the operator should be running in.

func GetPVCSelectedNodeName

func GetPVCSelectedNodeName(pvc *corev1.PersistentVolumeClaim) string

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func IndexOfString

func IndexOfString(a []string, v string) int

func IsPodUnschedulable

func IsPodUnschedulable(pod *corev1.Pod) bool

k8s Pod helper functions

func MergeMap

func MergeMap(destination map[string]string, sources ...map[string]string) map[string]string

MergeMap will take two maps, merging the entries of the source map into destination map. If both maps share the same key then destination's value for that key will be overwritten with what's in source.

func RangeInt

func RangeInt(min, max, step int) []int

func RemoveValueFromStringArray

func RemoveValueFromStringArray(a []string, v string) []string

func ResourcesHaveSameHash

func ResourcesHaveSameHash(r1, r2 Annotated) bool

func SearchMap

func SearchMap(mapToSearch map[string]interface{}, key string) map[string]interface{}

SearchMap will recursively search a map looking for a key with a value of another map

Types

type Annotated

type Annotated interface {
	GetAnnotations() map[string]string
	SetAnnotations(annotations map[string]string)
}

type RunModeType

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

type StringSet

type StringSet map[string]bool

StringSet helper functions

func GetNodeNameSet

func GetNodeNameSet(nodes []*corev1.Node) StringSet

k8s Node helper functions

func GetPodNameSet

func GetPodNameSet(pods []*corev1.Pod) StringSet

func GetPodNodeNameSet

func GetPodNodeNameSet(pods []*corev1.Pod) StringSet

func IntersectionStringSet

func IntersectionStringSet(a, b StringSet) StringSet

func SubtractStringSet

func SubtractStringSet(a, b StringSet) StringSet

func UnionStringSet

func UnionStringSet(a, b StringSet) StringSet

Jump to

Keyboard shortcuts

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