util

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEnvVarNotDefined = errors.New("environment variable not defined")

Functions

func ContainsAll

func ContainsAll[T comparable](a, b []T) bool

ContainsAll returns true if a contains all elements of b.

func EmptyIfNil

func EmptyIfNil[T any](s []T) []T

EmptyIfNil returns an empty slice if the input is nil.

func MergeRenderedPodLabels added in v0.4.0

func MergeRenderedPodLabels(podLabels, tmpl, vars map[string]string) error

func ParseEnv

func ParseEnv(envVariable string) (string, error)

func PtrIsNonZero

func PtrIsNonZero(ptr *int32) bool

func RenderPodLabels added in v0.4.0

func RenderPodLabels(tmpl, vars map[string]string) (map[string]string, error)

func SortItems

func SortItems[T any](items []T, sortBy SortBy, order SortOrder, nameFn func(T) string, dateFns ...func(T) time.Time)

SortItems sorts a slice in-place by name or date fields using accessor functions.

func SplitAndTrimString

func SplitAndTrimString(s, sep string) []string

SplitAndTrimString returns a new slice from a string separated by the given separator with all empty entries removed.

Types

type SortBy

type SortBy string

SortBy defines the sorting criteria.

const (
	// SortByName sorts by string comparison.
	SortByName SortBy = "name"
	// SortByDate sorts by creation date.
	SortByDate SortBy = "date"
	// SortByLastUpdate sorts by last run time.
	SortByLastUpdate SortBy = "last_update"
)

type SortOrder

type SortOrder string

SortOrder defines the sorting direction.

const (
	// SortAsc sorts in ascending order.
	SortAsc SortOrder = "asc"
	// SortDesc sorts in descending order.
	SortDesc SortOrder = "desc"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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