functions

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: AGPL-3.0 Imports: 27 Imported by: 4 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 logging.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 added in v1.1.0

func ForceDelete[T client.Object](ctx context.Context, logger logging.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 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 MapFilter added in v1.1.0

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

func MapFilterWithPrefix added in v1.1.0

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 added in v1.1.0

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 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 ParseFromSecretData added in v1.1.0

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

func ParseGVK

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

func Ptr added in v1.1.0

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 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