util

package
v4.3.1-0...-b3ed4f6 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareChannelVersion

func CompareChannelVersion(v1, v2 string) (v1IsLarger bool, err error)

func CompareConfigMap

func CompareConfigMap(configMap *corev1.ConfigMap, existingConfigMap *corev1.ConfigMap) (needUpdate bool)

func CompareSecret

func CompareSecret(secret *corev1.Secret, existingSecret *corev1.Secret) (needUpdate bool)

func Contains

func Contains(list []string, s string) bool

func Differs

func Differs(list []string, s string) bool

func EnsureLabelsForConfigMap

func EnsureLabelsForConfigMap(cm *corev1.ConfigMap, labels map[string]string)

func EnsureLabelsForRoute

func EnsureLabelsForRoute(r *ocproute.Route, labels map[string]string)

func EnsureLabelsForSecret

func EnsureLabelsForSecret(secret *corev1.Secret, labels map[string]string)

func EnsureLabelsForService

func EnsureLabelsForService(s *corev1.Service, labels map[string]string)

func GetInstallScope

func GetInstallScope() string

GetInstallScope returns the scope of the installation

func GetIsolatedMode

func GetIsolatedMode() bool

func GetOperatorNamespace

func GetOperatorNamespace() string

GetOperatorNamespace returns the Namespace of the operator

func GetWatchNamespace

func GetWatchNamespace() string

GetWatchNamespace returns the Namespace of the operator

func GetoperatorCheckerMode

func GetoperatorCheckerMode() bool

func MergeCR

func MergeCR(defaultCR, changedCR []byte) map[string]interface{}

MergeCR deep merge two custom resource spec

func ObjectToNewUnstructured

func ObjectToNewUnstructured(obj interface{}) (*unstructured.Unstructured, error)

func ResourceExists

func ResourceExists(dc discovery.DiscoveryInterface, apiGroupVersion, kind string) (bool, error)

ResourceExists returns true if the given resource kind exists in the given api groupversion

func ResourceNamespaced

func ResourceNamespaced(dc discovery.DiscoveryInterface, apiGroupVersion, kind string) (bool, error)

ResourceNamespaced returns true if the given resource is namespaced

func SanitizeObjectString

func SanitizeObjectString(jsonPath string, data interface{}) (string, error)

SanitizeObjectString takes a string, i.e. .metadata.namespace, and a K8s object and returns a string got from K8s object. The required string is sanitized because the values are YAML fields in a K8s object. Ensures that:

  1. the field actually exists, otherwise returns an error
  2. extracts the value from the K8s Service's field, the value will be stringified

func StringSliceContentEqual

func StringSliceContentEqual(a, b []string) bool

StringSliceContentEqual checks if the contant from two string slice are the same

func WaitTimeout

func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool

WaitTimeout waits for the waitgroup for the specified max timeout. Returns true if waiting timed out.

Types

type ConfigMapRef

type ConfigMapRef struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Key       string `json:"key"`
}

type DefaultObjectRef

type DefaultObjectRef struct {
	Required        bool          `json:"required,omitempty"`
	ConfigMapKeyRef *ConfigMapRef `json:"configMapKeyRef,omitempty"`
	SecretRef       *SecretRef    `json:"secretKeyRef,omitempty"`
	// RouteRef        *RouteRef     `json:"routePathRef,omitempty"`
	ObjectRef    *ObjectRef `json:"objectRef,omitempty"`
	DefaultValue string     `json:"defaultValue,omitempty"`
}

type MultiErr

type MultiErr struct {
	Errors []string
}

MultiErr is a multiple error slice

func (*MultiErr) Add

func (mer *MultiErr) Add(err error)

Add appends error message

func (*MultiErr) Error

func (mer *MultiErr) Error() string

Error is the error message

type ObjectRef

type ObjectRef struct {
	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
	Path       string `json:"path"`
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
}

type SecretRef

type SecretRef struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Key       string `json:"key"`
}

type TemplateValueRef

type TemplateValueRef struct {
	Required        bool              `json:"required,omitempty"`
	Default         *DefaultObjectRef `json:"default,omitempty"`
	ConfigMapKeyRef *ConfigMapRef     `json:"configMapKeyRef,omitempty"`
	SecretRef       *SecretRef        `json:"secretKeyRef,omitempty"`
	// RouteRef        *RouteRef         `json:"routePathRef,omitempty"`
	ObjectRef *ObjectRef `json:"objectRef,omitempty"`
}

Jump to

Keyboard shortcuts

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