functions

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Json = &jsonFeatures{}

Functions

func AsOwner

func AsOwner(r client.Object, controller ...bool) metav1.OwnerReference

func CleanerNanoid

func CleanerNanoid(n int) string

func Contains

func Contains[T comparable](arr []T, item T) bool

func ContainsAll

func ContainsAll[T comparable](arr []T, items []T) bool

func ContainsAllWithPredicate

func ContainsAllWithPredicate[T comparable, K comparable](arr []T, items []T, predicate func(item T) K) bool

func ContainsFinalizers

func ContainsFinalizers(obj client.Object, finalizers ...string) bool

func DefaultIfNil

func DefaultIfNil[T any](v *T) T

func DeleteAndWait

func DeleteAndWait(ctx context.Context, logger logging.Logger, kcli client.Client, resources ...client.Object) error

func Exec

func Exec(command ...string) (err error, stdout *bytes.Buffer, stderr *bytes.Buffer)

func Filter

func Filter[T comparable](from []T, items []T, filterFunc func(fromItem T, targetItem T) bool) []T

func FilterObservabilityAnnotations

func FilterObservabilityAnnotations(ann map[string]string) map[string]string

func GVK

func HasOwner

func HasOwner(obj client.Object) bool

func IfThenElse

func IfThenElse[T any](cond bool, v T, y T) T

func IfThenElseFn

func IfThenElseFn[T any](cond bool, v1 func() T, v2 func() T) T

func IntoMap

func IntoMap(value any, targetMap any) error

func IsOwner

func IsOwner(obj client.Object, ownerRef metav1.OwnerReference) bool

func JsonConvert

func JsonConvert[T any](from any) (T, error)

func Kubectl

func Kubectl(args ...string) (stdout *bytes.Buffer, err error)

func KubectlApply

func KubectlApply(ctx context.Context, cli client.Client, obj client.Object) error

func KubectlApplyExec

func KubectlApplyExec(ctx context.Context, stdin ...[]byte) (err error)

func KubectlDelete

func KubectlDelete(namespace, resourceRef string) error

func KubectlGet

func KubectlGet(namespace string, resourceRef string) ([]byte, error)

func MapContains

func MapContains[T comparable](destination map[string]T, source map[string]T) bool

MapContains checks if `destination` contains all keys from `source`

func MapEqual

func MapEqual[K comparable, V comparable](first map[K]V, second map[K]V) bool

func MapHasKey

func MapHasKey[K comparable, V any](m map[K]V, key K) bool

func MapKeys

func MapKeys[K comparable, V any](m map[K]V) []K

func MapMerge added in v1.0.2

func MapMerge[K comparable, V any](source ...map[K]V) map[K]V

func MapSet

func MapSet[T any](m *map[string]T, key string, value T)

MapSet sets a key, value in a map. If a map is nil, it firsts initializes the map

func MapValues

func MapValues[K comparable, V any](m map[K]V) []V

func Md5

func Md5(b []byte) string

func NN

func NN(namespace, name string) types.NamespacedName

func New

func New[T any](v T) *T

func ParseFromMap

func ParseFromMap[T any, K any](m map[string]K) (*T, error)

func ParseFromSecret

func ParseFromSecret[T any](secret *corev1.Secret) (*T, error)

func ParseGVK

func ParseGVK(apiVersion string, kind string) schema.GroupVersionKind

func RegularPlural

func RegularPlural(singular string) string

RegularPlural is used to pluralize group of k8s CRDs from kind It is copied from https://github.com/kubernetes-sigs/kubebuilder/blob/afce6a0e8c2a6d5682be07bbe502e728dd619714/pkg/model/resource/utils.go#L71

func RolloutRestart

func RolloutRestart(c client.Client, kind Restartable, namespace string, labels map[string]string) error

func Sha1Sum

func Sha1Sum(b []byte) string

func ToBase64StringFromJson

func ToBase64StringFromJson(v interface{}) (string, error)

Types

type JsonFeatures

type JsonFeatures interface {
	ToB64Url(v interface{}) (string, error)
	ToB64String(v interface{}) (string, error)
	FromB64Url(s string, v interface{}) error
	FromTo(v interface{}, rt interface{}) error
	FromRawMessage(msg json.RawMessage, result interface{}) error
}

type Restartable

type Restartable string
const (
	Deployment  Restartable = "deployment"
	StatefulSet Restartable = "statefulset"
)

Jump to

Keyboard shortcuts

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