Documentation ¶
Overview ¶
Package data contains functions for working with unstructured values like []interface or map[string]interface{}. It allows reading/writing to these values without having to convert to structured items.
Index ¶
- func GetValue(data map[string]interface{}, keys ...string) (interface{}, bool)
- func GetValueFromAny(data interface{}, keys ...string) (interface{}, bool)
- func GetValueN(data map[string]interface{}, keys ...string) interface{}
- func MergeMaps(base, overlay map[string]interface{}) map[string]interface{}
- func MergeMapsConcatSlice(base, overlay map[string]interface{}) map[string]interface{}
- func PutValue(data map[string]interface{}, val interface{}, keys ...string)
- func RemoveValue(data map[string]interface{}, keys ...string) (interface{}, bool)
- type List
- type Object
- func (o Object) Bool(key ...string) bool
- func (o Object) Map(names ...string) Object
- func (o Object) Set(key string, obj interface{})
- func (o Object) SetNested(obj interface{}, key ...string)
- func (o Object) Slice(names ...string) (result []Object)
- func (o Object) String(names ...string) string
- func (o Object) StringSlice(names ...string) []string
- func (o Object) Values() (result []Object)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetValue ¶
GetValue works similar to GetValueFromAny, but can only process maps. Kept this way to avoid breaking changes with the previous interface, GetValueFromAny should be used in most cases since that can handle slices as well.
func GetValueFromAny ¶
GetValueFromAny retrieves a value from the provided collection, which must be a map[string]interface or a []interface. Keys are always strings. For a map, a key denotes the key in the map whose value we want to retrieve. For the slice, it denotes the index (starting at 0) of the value we want to retrieve. Returns the retrieved value (if any) and a bool indicating if the value was found.
func MergeMapsConcatSlice ¶
func PutValue ¶
PutValue updates the value of a given map at the index specified by keys that denote the path to the value in the nested structure of the map. If there is no current entry at a key, a new map is created for that value.
func RemoveValue ¶
RemoveValue removes a value from data. Keys should be in order denoting the path to the value in the nested structure of the map. For example, passing []string{"metadata", "annotations"} will make the function remove the "annotations" key from the "metadata" sub-map. Returns the removed value (if any) and a bool indicating if the value was found.