values

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertMap

func ConvertMap[T any](m Map) (T, error)

ConvertMap translates a Map to a T, via JSON

func GetPathAs

func GetPathAs[T any](m Map, name string) T

GetPathAs is a helper function to get a patch value and cast it to a specified type. If the path is not found, or the cast fails, the zero value is returned.

Types

type Map

type Map map[string]any

Map is a wrapper around an untyped map, used throughout the operator codebase for generic access.

func CastAsMap

func CastAsMap(current any) (Map, bool)

CastAsMap casts a value to a Map, if possible.

func MapFromJSON

func MapFromJSON(input []byte) (Map, error)

MapFromJSON constructs a Map from JSON

func MapFromYAML

func MapFromYAML(input []byte) (Map, error)

MapFromYAML constructs a Map from YAML

func MustCastAsMap

func MustCastAsMap(current any) Map

MustCastAsMap casts a value to a Map; if the value is not a map, it will panic..

func (Map) GetPath

func (m Map) GetPath(name string) (any, bool)

func (Map) GetPathMap

func (m Map) GetPathMap(s string) (Map, bool)

func (Map) GetPathString

func (m Map) GetPathString(s string) string

GetPathString is a helper around TryGetPathAs[string] to allow usage as a method (otherwise impossible with generics)

func (Map) GetPathStringOr

func (m Map) GetPathStringOr(s string, def string) string

GetPathStringOr is a helper around TryGetPathAs[string] to allow usage as a method (otherwise impossible with generics), with an allowance for a default value if it is not found/not set.

func (Map) JSON

func (m Map) JSON() string

JSON serializes a Map to a JSON string.

func (Map) MergeFrom

func (m Map) MergeFrom(other Map)

MergeFrom does a key-wise merge between the current map and the passed in map. The other map has precedence, and the result will modify the current map.

func (Map) SetPath

func (m Map) SetPath(paths string, value any) error

SetPath applies values from a path like `key.subkey`, `key.[0].var`, or `key.[name:foo]`.

func (Map) SetPaths

func (m Map) SetPaths(paths ...string) error

SetPaths applies values from input like `key.subkey=val`

func (Map) SetSpecPaths

func (m Map) SetSpecPaths(paths ...string) error

SetSpecPaths applies values from input like `key.subkey=val`, and applies them under 'spec'

func (Map) YAML

func (m Map) YAML() string

YAML serializes a Map to a YAML string.

Jump to

Keyboard shortcuts

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