gera

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

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

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]) Copy added in v1.17.0

func (w *WrapMap[K, V]) Copy() Map[K, V]

func (*WrapMap[K, V]) Del added in v1.17.0

func (w *WrapMap[K, V]) Del(key K) (ok bool)

func (*WrapMap[K, V]) Flattened

func (w *WrapMap[K, V]) Flattened() (map[K]V, error)

func (*WrapMap[K, V]) FlattenedParent added in v1.17.0

func (w *WrapMap[K, V]) FlattenedParent() (map[K]V, error)

func (*WrapMap[K, V]) Get

func (w *WrapMap[K, V]) Get(key K) (value V, ok bool)

func (*WrapMap[K, V]) Has

func (w *WrapMap[K, V]) Has(key K) bool

func (*WrapMap[K, V]) HierarchyContains

func (w *WrapMap[K, V]) HierarchyContains(m Map[K, V]) bool

func (*WrapMap[K, V]) IsHierarchyRoot

func (w *WrapMap[K, V]) IsHierarchyRoot() bool

func (*WrapMap[K, V]) Len

func (w *WrapMap[K, V]) Len() int

func (*WrapMap[K, V]) MarshalYAML added in v1.17.0

func (w *WrapMap[K, V]) MarshalYAML() (interface{}, error)

func (*WrapMap[K, V]) Raw

func (w *WrapMap[K, V]) Raw() map[K]V

func (*WrapMap[K, V]) RawCopy added in v1.17.0

func (w *WrapMap[K, V]) RawCopy() map[K]V

func (*WrapMap[K, V]) Set

func (w *WrapMap[K, V]) Set(key K, value V) (ok bool)

func (*WrapMap[K, V]) UnmarshalYAML

func (w *WrapMap[K, V]) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*WrapMap[K, V]) Unwrap

func (w *WrapMap[K, V]) Unwrap() Map[K, V]

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 (w *WrapMap[K, V]) WithMarshalYAML(marshalYAML func(w Map[K, V]) (interface{}, error)) *WrapMap[K, V]

func (*WrapMap[K, V]) WithUnmarshalYAML added in v1.17.0

func (w *WrapMap[K, V]) WithUnmarshalYAML(unmarshalYAML func(w Map[K, V], unmarshal func(interface{}) error) error) *WrapMap[K, V]

func (*WrapMap[K, V]) Wrap

func (w *WrapMap[K, V]) Wrap(m Map[K, V]) Map[K, V]

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).

func (*WrapMap[K, V]) WrappedAndFlattened

func (w *WrapMap[K, V]) WrappedAndFlattened(m Map[K, V]) (map[K]V, error)

Jump to

Keyboard shortcuts

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