Documentation ¶
Overview ¶
Package nodeutils provides utility methods to perform operations on yaml node
Index ¶
- Constants
- Variables
- func ConvertMapToNode(envs map[string]string) (*yaml.Node, error)
- func ConvertNodeToMap(node *yaml.Node) (envs map[string]string, err error)
- func ConvertNodeToMapInterface(node *yaml.Node) (envs map[string]interface{}, err error)
- func CreateMappingNode(key string) []*yaml.Node
- func CreateNode(nodeKey Key) []*yaml.Node
- func CreateScalarNode(key, value string) []*yaml.Node
- func CreateSequenceNode(key string) []*yaml.Node
- func DeleteNodes(src, dst *yaml.Node, opts ...PatchStrategyOpts) (bool, error)
- func Equal(node1, node2 *yaml.Node) (bool, error)
- func FindNode(node *yaml.Node, opts ...Options) *yaml.Node
- func GetNodeIndex(node []*yaml.Node, key string) int
- func MergeNodes(src, dst *yaml.Node) (bool, error)
- func NotEqual(node1, node2 *yaml.Node) (bool, error)
- func UniqNodes(nodes []*yaml.Node) []*yaml.Node
- type CfgNode
- type Key
- type Options
- type PatchStrategyOptions
- type PatchStrategyOpts
Constants ¶
const ( PatchStrategyReplace = "replace" PatchStrategyMerge = "merge" )
const (
NodeTagStr = "!!str"
)
Variables ¶
var ( ErrDifferentArgumentsTypes = errors.New("src and dst must be of same type") ErrNonPointerArgument = errors.New("dst must be a pointer") )
var (
ErrNodeNotFound = errors.New("node not found")
)
Functions ¶
func ConvertMapToNode ¶
ConvertMapToNode converts map[string]string to yaml node
func ConvertNodeToMap ¶
ConvertNodeToMap converts yaml node to map[string]string
func ConvertNodeToMapInterface ¶
ConvertNodeToMapInterface converts yaml node to map[string]interface
func CreateMappingNode ¶
func CreateMappingNode(key string) []*yaml.Node
CreateMappingNode creates yaml node based on node key
func CreateNode ¶
func CreateNode(nodeKey Key) []*yaml.Node
CreateNode creates yaml node based on node key Type
func CreateScalarNode ¶
func CreateScalarNode(key, value string) []*yaml.Node
CreateScalarNode creates yaml node based on node key and value
func CreateSequenceNode ¶
func CreateSequenceNode(key string) []*yaml.Node
CreateSequenceNode creates yaml node based on node key
func DeleteNodes ¶
func DeleteNodes(src, dst *yaml.Node, opts ...PatchStrategyOpts) (bool, error)
DeleteNodes delete nodes in dst as per patchStrategy prior performing merge
func FindNode ¶
func FindNode(node *yaml.Node, opts ...Options) *yaml.Node
FindNode parse the yaml node and return the matched node based on Config Options passed
func GetNodeIndex ¶
GetNodeIndex retrieves node index of specific node object value; yaml nodes are stored in arrays for all value types. Ex: refer https://pkg.go.dev/gopkg.in/yaml.v3#pkg-overview
func MergeNodes ¶
MergeNodes to merge two yaml nodes src(source) to dst(destination) node
Types ¶
type CfgNode ¶
type CfgNode struct { ForceCreate bool // Set to True to create nodes of missing keys. Ex: True for Add/Update operations on yaml node, False for Get/Delete operations on yaml node Keys []Key // keys of config nodes passed in hierarchical order. Ex: [ClientOptions, CLI, DiscoverySources] to get the DiscoverySources node from ClientOptions yaml node }
CfgNode options to be used to find specific node based on arrays of Keys passed in hierarchical order
type Options ¶
type Options func(config *CfgNode)
func WithForceCreate ¶
func WithForceCreate() Options
type PatchStrategyOptions ¶
type PatchStrategyOpts ¶
type PatchStrategyOpts func(options *PatchStrategyOptions)
func WithPatchStrategies ¶
func WithPatchStrategies(patchStrategies map[string]string) PatchStrategyOpts
func WithPatchStrategyKey ¶
func WithPatchStrategyKey(key string) PatchStrategyOpts