Documentation
¶
Index ¶
- Variables
- func AsPath(xpath string) []string
- func Base(path []string) string
- func CopyFields(target, source map[string]any)
- func CreateField[T any](obj map[string]any, value T, fields ...string) error
- func Dir(path []string) []string
- func FieldsOf(obj map[string]any) []string
- func FromUnstructured(target any, source map[string]any) error
- func GetField[T any](obj map[string]any, fields ...string) (T, error)
- func GetFieldObject(obj map[string]any, fields ...string) (map[string]any, error)
- func GetOrCreateField[T any](obj map[string]any, defaultValue T, fields ...string) (T, error)
- func RecursiveCreateField[T any](obj map[string]any, value T, fields ...string) error
- func ToUnstructured(obj any) (map[string]any, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound when a field is not found in an object ErrNotFound = errors.New("not found") // ErrNilObject when an object is unexpectedly nil ErrNilObject = errors.New("nil object") // ErrNotObject when a field is not an object ErrNotObject = errors.New("not an object") // ErrNotArray when a field is not an array ErrNotArray = errors.New("not an array") )
Functions ¶
func AsPath ¶
AsPath translates the given simplified xpath expression into a sequence of path entries. This ia very shallow xpath formatter, not full xpath compliant
func CopyFields ¶
CopyFields copies all unstructured fields from an source to a target
func CreateField ¶
CreateField creates a field with a value at the given path
func FromUnstructured ¶
FromUnstructured fills a target value with the field values from an unstructured map
func GetFieldObject ¶
GetFieldObject returns the object holding the given field path
func GetOrCreateField ¶
GetOrCreateField access a field at the given path, it creates the field with the given defaultValue if it did not exist
func RecursiveCreateField ¶
RecursiveCreateField creates a field with a value at the given path, it does create the parent path objects as needed
Types ¶
This section is empty.