functions

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanerNanoid

func CleanerNanoid(n int) (string, error)

func CleanerNanoidOrDie

func CleanerNanoidOrDie(n int) string

func DefaultIfNil

func DefaultIfNil[T any](v *T, defaultVal ...T) T

func First

func First[T any](items []T) T

func FxErrorHandler

func FxErrorHandler() fx.Option

func GVK

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

func GenReadableName

func GenReadableName(seed string, maxMatchLen ...int) string

GenReadableName generates a readable name from a given string (seed). It finds matches in the seed following regex `^([[:lower:]]|[[:digit:]]|-)*`. It also limits maximum match text length to 20 (by default)

func GenValidK8sResourceNames

func GenValidK8sResourceNames(seed string, count int) []string

TODO (nxtcoder17): need to benchmark this function

func IsNil

func IsNil[T any](v T) bool

IsNil is useful when checking for a typed pointer for primitive types, use v == nil

func IsValidK8sResourceName

func IsValidK8sResourceName(name string) bool

func JsonConversion

func JsonConversion(from any, to any) error

func JsonConvert

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

func JsonConvertP

func JsonConvertP[T any](from any) (*T, error)

func K8sObjToMap

func K8sObjToMap(obj client.Object) (map[string]any, error)

func K8sObjToYAML

func K8sObjToYAML(obj client.Object) ([]byte, error)

func Must

func Must[T any](value T, err error) T

func NN

func NN(namespace, name string) types.NamespacedName

func New

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

func NewTypeFromPointer

func NewTypeFromPointer[T any]() T

func ParseOnlyOption

func ParseOnlyOption[T any](item []T) *T

func Reduce

func Reduce[T any, V any](items []T, reducerFn func(V, T), value V) V

func StringReverse

func StringReverse(x string) string

func ToBase64StringFromJson

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

func ToBase64UrlFromJson

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

func UUID

func UUID(size ...int) string

UUID returns a UUID string of the given size, if specified, otherwise a default size of 16 is used.

Types

type ErrH

type ErrH struct {
	Logger logging.Logger
}

func (*ErrH) HandleError

func (e *ErrH) HandleError(err error)

func (*ErrH) String

func (e *ErrH) String() string

Jump to

Keyboard shortcuts

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