maps

package
v3.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineMapTrees

func CombineMapTrees[K comparable](destination map[K]interface{}, input map[K]interface{})

CombineMapTrees recursively copies all the values from the input map into the destination map preserving any missing entries in the destination

func GetMapValueAsIntViaPath

func GetMapValueAsIntViaPath(m map[string]interface{}, path string) int

GetMapValueAsIntViaPath returns the int value at the given path mean `m["foo"]["bar"]["whatnot"]`

func GetMapValueAsMapViaPath

func GetMapValueAsMapViaPath(m map[string]interface{}, path string) map[string]interface{}

GetMapValueAsMapViaPath returns the map value at the given path mean `m["foo"]["bar"]["whatnot"]`

func GetMapValueAsStringViaPath

func GetMapValueAsStringViaPath(m map[string]interface{}, path string) string

GetMapValueAsStringViaPath returns the string value at the given path mean `m["foo"]["bar"]["whatnot"]`

func GetMapValueViaPath

func GetMapValueViaPath(m map[string]interface{}, path string) interface{}

GetMapValueViaPath returns the value at the given path mean `m["foo"]["bar"]["whatnot"]`

func KeyValuesToMap

func KeyValuesToMap(values []string) map[string]string

KeyValuesToMap converts the set of values of the form "foo=abc" into a map

func MapHasValue added in v3.4.8

func MapHasValue[K comparable, V comparable](m map[K]V, value V) bool

StringHasValue returns true if the given map contains the given value

func MapKeys

func MapKeys[V interface{}](m map[string]V) []string

MapKeys returns the keys of a given map

func MapToKeyValues

func MapToKeyValues(values map[string]string) []string

MapToKeyValues converts the map into a sorted array of key/value pairs

func MapToString

func MapToString(m map[string]string) string

MapToString converts the map to a string

func MergeMaps

func MergeMaps[K comparable, V interface{}](maps ...map[K]V) map[K]V

MergeMaps merges all the maps together with the entries in the last map overwriting any earlier values

so if you want to add some annotations to a resource you can do resource.Annotations = kube.MergeMaps(resource.Annotations, myAnnotations)

func SetMapValueViaPath

func SetMapValueViaPath(m map[string]interface{}, path string, value interface{})

SetMapValueViaPath sets the map key using the given path which supports the form `foo.bar.whatnot` to mean `m["foo"]["bar"]["whatnot"]` lazily creating maps as the path is navigated

func StringMapHasValue

func StringMapHasValue(m map[string]string, value string) bool

StringMapHasValue returns true if the given map contains the given value

func ToObjectMap

func ToObjectMap(object interface{}) (map[string]interface{}, error)

ToObjectMap converts the given object into a map of strings/maps using YAML marshalling

Types

This section is empty.

Jump to

Keyboard shortcuts

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