Documentation ¶
Overview ¶
Package gera implements a hierarchical key-value store.
A gera.Map uses a map[string]interface{} as backing store, and it can wrap other gera.Map instances. Values in child maps override any value provided by a gera.Map that's wrapped in the hierarchy.
The name is reminiscent of hiera, as in hierarchical, but it was deemed desirable to avoid future confusion with the Hiera KV store used by Puppet, a different product altogether, so instead of the ancient Greek root, "gera" comes from the Italian root instead where "hi" becomes a soft "g".
Index ¶
- func FlattenStack[K comparable, V any](maps ...Map[K, V]) (flattened map[K]V, err error)
- type Map
- type WrapMap
- func (w *WrapMap[K, V]) Copy() Map[K, V]
- func (w *WrapMap[K, V]) Del(key K) (ok bool)
- func (w *WrapMap[K, V]) Flattened() (map[K]V, error)
- func (w *WrapMap[K, V]) FlattenedParent() (map[K]V, error)
- func (w *WrapMap[K, V]) Get(key K) (value V, ok bool)
- func (w *WrapMap[K, V]) Has(key K) bool
- func (w *WrapMap[K, V]) HierarchyContains(m Map[K, V]) bool
- func (w *WrapMap[K, V]) IsHierarchyRoot() bool
- func (w *WrapMap[K, V]) Len() int
- func (w *WrapMap[K, V]) MarshalYAML() (interface{}, error)
- func (w *WrapMap[K, V]) Raw() map[K]V
- func (w *WrapMap[K, V]) RawCopy() map[K]V
- func (w *WrapMap[K, V]) Set(key K, value V) (ok bool)
- func (w *WrapMap[K, V]) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (w *WrapMap[K, V]) Unwrap() Map[K, V]
- func (w *WrapMap[K, V]) WithMarshalYAML(marshalYAML func(w Map[K, V]) (interface{}, error)) *WrapMap[K, V]
- func (w *WrapMap[K, V]) WithUnmarshalYAML(unmarshalYAML func(w Map[K, V], unmarshal func(interface{}) error) error) *WrapMap[K, V]
- func (w *WrapMap[K, V]) Wrap(m Map[K, V]) Map[K, V]
- func (w *WrapMap[K, V]) WrappedAndFlattened(m Map[K, V]) (map[K]V, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlattenStack ¶
func FlattenStack[K comparable, V any](maps ...Map[K, V]) (flattened map[K]V, err error)
Types ¶
type Map ¶
type Map[K comparable, V any] interface { Wrap(m Map[K, V]) Map[K, V] IsHierarchyRoot() bool HierarchyContains(m Map[K, V]) bool Unwrap() Map[K, V] Has(key K) bool Len() int Get(key K) (V, bool) Set(key K, value V) bool Del(key K) bool Flattened() (map[K]V, error) FlattenedParent() (map[K]V, error) WrappedAndFlattened(m Map[K, V]) (map[K]V, error) Raw() map[K]V Copy() Map[K, V] RawCopy() map[K]V }
type WrapMap ¶
type WrapMap[K comparable, V any] struct { // contains filtered or unexported fields }
func MakeMap ¶
func MakeMap[K comparable, V any]() *WrapMap[K, V]
func MakeMapWithMap ¶
func MakeMapWithMap[K comparable, V any](fromMap map[K]V) *WrapMap[K, V]
func MakeMapWithMapCopy ¶
func MakeMapWithMapCopy[K comparable, V any](fromMap map[K]V) *WrapMap[K, V]
func (*WrapMap[K, V]) FlattenedParent ¶ added in v1.17.0
func (*WrapMap[K, V]) HierarchyContains ¶
func (*WrapMap[K, V]) IsHierarchyRoot ¶
func (*WrapMap[K, V]) MarshalYAML ¶ added in v1.17.0
func (*WrapMap[K, V]) UnmarshalYAML ¶
func (*WrapMap[K, V]) Unwrap ¶
Unwraps this map from its parent. Returns a pointer to the former parent which was just unwrapped.
func (*WrapMap[K, V]) WithMarshalYAML ¶ added in v1.17.0
func (*WrapMap[K, V]) WithUnmarshalYAML ¶ added in v1.17.0
func (*WrapMap[K, V]) Wrap ¶
Wraps this map around the gera.Map m, which becomes the new parent. Returns a pointer to the composite map (i.e. to itself in its new state).