functions

package
v0.0.0-...-51f2913 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

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[T client.Object](ctx context.Context, logger *slog.Logger, kcli client.Client, resources ...T) 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 ForceDelete

func ForceDelete[T client.Object](ctx context.Context, logger *slog.Logger, kcli client.Client, resources ...T) error

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 IsGVKInstalled

func IsGVKInstalled(client client.Client, apiVersion, kind string) bool

checks whether CRD are installed on the cluster

func IsOwner

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

func JsonConvert

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

func KubectlApply

func KubectlApply(ctx context.Context, cli client.Client, obj client.Object) 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 MapFilter

func MapFilter[K string, V any](m map[K]V, filters ...func(k K, v V) bool) map[K]V

func MapFilterWithPrefix

func MapFilterWithPrefix[K string, V any](m map[K]V, keyPrefix string) map[K]V

func MapHasKey

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

func MapJoin

func MapJoin[K comparable, V any](first *map[K]V, second map[K]V)

func MapKeys

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

func MapMerge

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 ParseFromSecretData

func ParseFromSecretData[T any](m map[string][]byte) (*T, error)

func ParseGVK

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

func Ptr

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

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 ContainerMessage

type ContainerMessage struct {
	State     string `json:"state,omitempty"`
	Pod       string `json:"pod,omitempty"`
	Container string `json:"container,omitempty"`
	Reason    string `json:"reason,omitempty"`
	Message   string `json:"message,omitempty"`
	ExitCode  int32  `json:"exitCode,omitempty"`
}

func GetMessagesFromPods

func GetMessagesFromPods(pods ...corev1.Pod) []ContainerMessage

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