Documentation ¶
Index ¶
- func ArrayFallback[T any](array []T, fallback []T) []T
- func CollectFnErr[T any](errContainer *MultiError, fn func() (T, error), rightFn func(T))
- func Elvis[T any](condition bool, leftValue T, rightValue T) T
- func IsJobComplete(job batchv1.Job) bool
- func IsJobFailed(job batchv1.Job) bool
- func IsPodReady(pod corev1.Pod) bool
- func K8sObjKeyStr(key types.NamespacedName) string
- func MapEqual[K comparable, V comparable](m1, m2 map[K]V) bool
- func MapFallback[K comparable, V any](mapValue map[K]V, fallback map[K]V) map[K]V
- func MapSortedKeys[K string | int, V any](data map[K]V) []K
- func Md5Hash(obj any) (string, error)
- func Md5HashOr(obj any, fallback string) string
- func MergeMaps[K comparable, V any](m1, m2 map[K]V) map[K]V
- func NewConfigMapItemsVolumeSource(configMapName string, items map[string]string) corev1.VolumeSource
- func NewConfigMapVolumeSource(configMapName string) corev1.VolumeSource
- func NewEmptyDirVolumeSource() corev1.VolumeSource
- func NewEnvVarSecretSource(secretName string, key string) *corev1.EnvVarSource
- func NewExecLifecycleHandler(command ...string) *corev1.LifecycleHandler
- func NewHostPathVolumeSource(path string) corev1.VolumeSource
- func NewHttpGetProbeHandler(path string, httpPort int32) corev1.ProbeHandler
- func NewReadWriteOncePVC(name string, storageClassName *string, storageRequest *resource.Quantity) corev1.PersistentVolumeClaim
- func NewResourceAvgUtilizationMetricSpec(name corev1.ResourceName, avgUnit *int32) acv2.MetricSpec
- func NewTcpSocketProbeHandler(tcpPort int32) corev1.ProbeHandler
- func ParallelRun[T any](fns ...func() T) []T
- func PointerDeRefer[T any](pointer *T, defaultValue T) T
- func PointerFallback[T any](pointer *T, fallback *T) *T
- func PointerFallbackAndDeRefer[T any](pointer *T, fallback *T, defaultValue T) T
- func StringFallback(str string, fallback string) string
- type MultiError
- type MultiTaggedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayFallback ¶
func ArrayFallback[T any](array []T, fallback []T) []T
ArrayFallback returns the first array if it is not empty, otherwise the second array.
func CollectFnErr ¶
func CollectFnErr[T any](errContainer *MultiError, fn func() (T, error), rightFn func(T))
CollectFnErr collects error from fn function, then execute rightFn function when the fn returns nil error.
func IsJobComplete ¶
func IsJobFailed ¶
func IsPodReady ¶
func K8sObjKeyStr ¶
func K8sObjKeyStr(key types.NamespacedName) string
func MapEqual ¶
func MapEqual[K comparable, V comparable](m1, m2 map[K]V) bool
MapEqual checks if two maps are equal.
func MapFallback ¶
func MapFallback[K comparable, V any](mapValue map[K]V, fallback map[K]V) map[K]V
func MapSortedKeys ¶
MapSortedKeys returns all sorted keys of a map.
func Md5HashOr ¶
Md5HashOr returns the md5 hash of the given object base on json marshal. when error occurs, return the fallback string.
func MergeMaps ¶
func MergeMaps[K comparable, V any](m1, m2 map[K]V) map[K]V
MergeMaps merges two maps into one, when there is a key conflict, prioritize using the value of m2.
func NewConfigMapItemsVolumeSource ¶
func NewConfigMapItemsVolumeSource(configMapName string, items map[string]string) corev1.VolumeSource
func NewConfigMapVolumeSource ¶
func NewConfigMapVolumeSource(configMapName string) corev1.VolumeSource
func NewEmptyDirVolumeSource ¶
func NewEmptyDirVolumeSource() corev1.VolumeSource
func NewEnvVarSecretSource ¶
func NewEnvVarSecretSource(secretName string, key string) *corev1.EnvVarSource
func NewExecLifecycleHandler ¶
func NewExecLifecycleHandler(command ...string) *corev1.LifecycleHandler
func NewHostPathVolumeSource ¶
func NewHostPathVolumeSource(path string) corev1.VolumeSource
func NewHttpGetProbeHandler ¶
func NewHttpGetProbeHandler(path string, httpPort int32) corev1.ProbeHandler
func NewReadWriteOncePVC ¶
func NewResourceAvgUtilizationMetricSpec ¶
func NewResourceAvgUtilizationMetricSpec(name corev1.ResourceName, avgUnit *int32) acv2.MetricSpec
func NewTcpSocketProbeHandler ¶
func NewTcpSocketProbeHandler(tcpPort int32) corev1.ProbeHandler
func ParallelRun ¶
func ParallelRun[T any](fns ...func() T) []T
ParallelRun executes the functions in parallel and wait for all functions to complete.
func PointerDeRefer ¶
func PointerDeRefer[T any](pointer *T, defaultValue T) T
func PointerFallback ¶
func PointerFallback[T any](pointer *T, fallback *T) *T
PointerFallback returns the first pointer if it is not nil, otherwise the second pointer.
func PointerFallbackAndDeRefer ¶
func PointerFallbackAndDeRefer[T any](pointer *T, fallback *T, defaultValue T) T
PointerFallbackAndDeRefer returns the first pointer if it is not nil, otherwise the second pointer, then dereference the pointer fallback with the defaultValue.
func StringFallback ¶
StringFallback returns the first string if it is not empty, otherwise the second string.
Types ¶
type MultiError ¶
type MultiError struct {
Errors []error
}
MultiError is a list of errors.
func AppendErrMsg ¶
func AppendErrMsg(err error, message string) *MultiError
func MergeErrors ¶
func MergeErrors(errs ...error) *MultiError
MergeErrors merges multiple errors into one.
func (*MultiError) Collect ¶
func (e *MultiError) Collect(err error) bool
func (*MultiError) Dry ¶
func (e *MultiError) Dry() error
Dry returns nil if there is no error in the container.
func (*MultiError) Error ¶
func (e *MultiError) Error() string
type MultiTaggedError ¶
MultiTaggedError is a list of errors with tags.
func MergeErrorsWithTag ¶
func MergeErrorsWithTag(errors map[string]error) *MultiTaggedError
MergeErrorsWithTag merges multiple errors into one with tags.
func (*MultiTaggedError) Error ¶
func (e *MultiTaggedError) Error() string