utils

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAStringAnyMap = errors.New("sub-map is not of type map[string]any")
	ErrNoPath           = errors.New("at least one path element needs to be specified")
	ErrMapNil           = errors.New("map is nil")
	ErrValueNotFound    = errors.New("value not found")
)

Functions

func GetNestedValue

func GetNestedValue(m map[string]any, path ...string) (any, error)

GetNestedValue traverses a map and looks for a value under the given path. If the value was not found, `ErrValueNotFound` will be returned.

func IsCRDNotFound

func IsCRDNotFound(err error) bool

IsCRDNotFound checks if the given error is a CRD not found error.

func IsManaged

func IsManaged() client.MatchingLabels

func MustMarshal

func MustMarshal(v any) []byte

MustMarshal returns the JSON encoding of v and panics if there is an error.

func SetLabel

func SetLabel(obj v1.Object, label string, value string)

func SetManagedBy

func SetManagedBy(obj v1.Object)

func SetNestedDefault

func SetNestedDefault(m map[string]any, v any, path ...string) error

SetNestedDefault traverses a map and sets a default value if no map entry exists yet under the given key.

func UpdateConditions

func UpdateConditions(conditions *[]metav1.Condition, newConditions []metav1.Condition) bool

UpdateConditions merges the "newConditions" into "conditions" while keeping the "LastTransitionTime" of unchanged conditions and removing stale conditions that are not present in "newConditions" anymore.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳