util

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotateTemplate added in v0.7.1

func AnnotateTemplate(dep *appsv1.Deployment, key, val string)

Annotates the passed deployment.spec.template.annotations

func CRC added in v0.7.1

func CRC(val string) string

Generates a CRC for the passed value

func CRCBytes added in v0.7.1

func CRCBytes(val []byte) string

Generates a CRC for the passed value

func ConfigMapComparer

func ConfigMapComparer(expected runtime.Object, found runtime.Object) bool

ConfigMap comparer

func DebugDumpObj

func DebugDumpObj(obj runtime.Object)

DebugDumpObj is used for debugging as needed. It dumps the YAML to the console for the passed object

func DeploymentComparer

func DeploymentComparer(expected runtime.Object, found runtime.Object) bool

Deployment comparer

func GetEnv

func GetEnv(container *corev1.Container, envName string) *corev1.EnvVar

gets the named environment variable from the passed container or nil

func GetJsonPathValue

func GetJsonPathValue(obj runtime.Object, jsonPath string) ([]byte, error)

GetJsonPathValue applies the passed JSONPath expression to the passed runtime object and returns the result of the parse. It's less friendly than the kubectl get -o=jsonpath= in that the passed JSON path has to be in the canonical format: "{.path...}" meaning 1) enclosed in curly braces and 2) starting with a period. A variety of errors are returned but an empty return value and nil error can also indicate that the provided JSON path didn't find anything in the passed resource.

func GetJsonPathValueU

func GetJsonPathValueU(unstructured map[string]interface{}, jsonPath string) ([]byte, error)

Same as GetJsonPathValue, except takes an unstructured instead of a runtime object

func IngressComparer

func IngressComparer(expected runtime.Object, found runtime.Object) bool

Ingress comparer (ingress annotations control passthrough) so - while these annotations are not part of the spec - if they change then its a reconcilement event.

func Int32Ptr

func Int32Ptr(i int32) *int32

Returns a pointer to the passed value

func Int64Ptr

func Int64Ptr(i int64) *int64

Returns a pointer to the passed value

func IsNuxeoAnnotation added in v0.7.1

func IsNuxeoAnnotation(annotationKey string) bool

returns true if the start of passed 'annotationKey' matches any Nuxeo annotation in common.NuxeoAnnotations

func IsOpenShift

func IsOpenShift() bool

Returns true if the operator is running in an OpenShift cluster. Else false = Kubernetes. False by default, unless SetIsOpenShift() was called prior to this call

func MergeOrAddEnvVar

func MergeOrAddEnvVar(container *corev1.Container, env corev1.EnvVar, separator string) error

MergeOrAddEnvVar searches the environment variable array in the passed container for an entry whose name matches the name of the passed environment variable struct. If found in the container array, the value of the passed variable is appended to the value of the existing variable, separated by the passed separator. Otherwise the passed environment variable struct is appended to the container env var array. E.g. given a container with an existing env var corev1.EnvVar{Name: "Z", Value "abc,123"}, then:

MergeOrAddEnvVar(someContainer, corev1.EnvVar{Name: "Z", Value "xyz,456"}, ",")

updates the variable value to: "abc,123,xyz,456". If either the passed environment variable or the existing one (by name) is a 'ValueFrom' environment variable then an error is returned.

func NopComparer

func NopComparer(runtime.Object, runtime.Object) bool

objects are always the same

func ObjectsDiffer

func ObjectsDiffer(expected interface{}, actual interface{}) (bool, error)

Used for debugging

func OnlyAddContainer

func OnlyAddContainer(dep *appsv1.Deployment, container corev1.Container) error

Adds the passed container to the passed deployment if not present in the deployment, otherwise errors

func OnlyAddEnvVar

func OnlyAddEnvVar(container *corev1.Container, env corev1.EnvVar) error

Adds the passed environment variable to the passed container if not present, otherwise errors

func OnlyAddVol

func OnlyAddVol(dep *appsv1.Deployment, vol corev1.Volume) error

Adds the passed volume to the passed deployment if not present in the container, otherwise errors

func OnlyAddVolMnt

func OnlyAddVolMnt(container *corev1.Container, mnt corev1.VolumeMount) error

Adds the passed volume mount to the passed container if not present in the container, otherwise errors

func PvcComparer

func PvcComparer(expected runtime.Object, found runtime.Object) bool

PersistentVolumeClaim comparer

func RouteComparer

func RouteComparer(expected runtime.Object, found runtime.Object) bool

OpenShift Route comparer

func SecretComparer

func SecretComparer(expected runtime.Object, found runtime.Object) bool

Secret comparer (operator may annotate secrets)

func ServiceComparer

func ServiceComparer(expected runtime.Object, found runtime.Object) bool

Service comparer (Kubernetes will update components of the service spec with values it chooses so the comparer has to ignore those)

func SetInt32If

func SetInt32If(v *int32, ifVal int32, thenVal int32)

set v = thenVal if v == ifVal

func SetIsOpenShift

func SetIsOpenShift(isOpenShift bool)

Sets operator state indicating that the operator believes it is running in an OpenShift cluster.

Types

This section is empty.

Jump to

Keyboard shortcuts

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