helper

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: MIT Imports: 25 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound error = errors.Sentinel("Key not found in map")

Functions

func DefaultControllerRateLimiter

func DefaultControllerRateLimiter[T comparable]() workqueue.TypedRateLimiter[T]

DefaultControllerRateLimiter is default rate limit to avoid burst the kubeapi-server

func DeleteItemFromSlice

func DeleteItemFromSlice(x any, index int) any

DeleteItemFromSlice is a generic function to remove item from a slice

func Diff

func Diff(expected, current any) string

Diff is cmp.Diff with custom function to compare slices with pretty.Sprint

func DiffMapString

func DiffMapString(expected, current map[string]string, excludeKeys []string) string

DiffMapString permit to diff map[string]string

func Get

func Get(m map[string]any, key string) (value any, err error)

Get permit to get value on from from key It return error if key not exist

func GetKubeClientTimeoutFromEnv

func GetKubeClientTimeoutFromEnv() (timeout time.Duration, err error)

func GetLogrusFormatterFromEnv

func GetLogrusFormatterFromEnv() logrus.Formatter

func GetLogrusLogLevelFromEnv

func GetLogrusLogLevelFromEnv() logrus.Level

func GetWatchNamespaceFromEnv

func GetWatchNamespaceFromEnv() (ns string, err error)

func GetZapFormatterFromDev

func GetZapFormatterFromDev() zapcore.Encoder

func GetZapLogLevelFromEnv

func GetZapLogLevelFromEnv() zapcore.Level

func HasCRD

func HasCRD(kclient kubernetes.Interface, groupVersion schema.GroupVersion) bool

HasCRD checks if the Kubernetes server supports the given groupVersion for CustomResourceDefinition.

Parameters: - kclient: A pointer to a Kubernetes clientset. - groupVersion: The groupVersion of the CustomResourceDefinition to check.

Returns: - bool: True if the server supports the given groupVersion, false otherwise.

func Merge

func Merge(dst any, srcs ...any) (err error)

Merge permit to merge unlimited same interface. The last src is the higher priority If some src are nil, it skip it It return error if dst is nil

func PrintVersion

func PrintVersion(logger logr.Logger, metricsAddr, probeAddr string)

func RandomString

func RandomString(length int) string

RandomString generates a random string from a subset of characters

func StringToSlice

func StringToSlice(value, separator string) (result []string)

StringToSlice permit to convert string with separator to slice Is like strings.Split with trimSpaces each items

func ToObject

func ToObject[srcType client.Object, dstType client.Object](o srcType) (res dstType)

ToObject permit to convert object type

func ToSlice added in v2.0.1

func ToSlice[srcType any](sList []*srcType) (res []srcType)

ToSlice convert slice of pointer object to slice of object

func ToSliceOfObject

func ToSliceOfObject[srcType any, dstType client.Object](sList []srcType) (res []dstType)

ToSliceOfObject permit to convert any slice of object to slice of client.Object Slice must not contain pointer

func ToSlicePtr added in v2.0.1

func ToSlicePtr[srcType any](sList []srcType) (res []*srcType)

ToSlicePtr convert slice of object to slice of pointer object

func UnZipBase64Decode

func UnZipBase64Decode(original string, originalObject any) error

func ZipAndBase64Encode

func ZipAndBase64Encode(originalObject any) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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