extensions

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteNode

func DeleteNode(node *yaml.Node, key *YamlIndex) error

DeleteNode will delete the key and content nodes for the given key

func GetKeyValue added in v0.18.0

func GetKeyValue(node *yaml.Node, key string) (*yaml.Node, error)

GetKeyValue gets the value of the key from the node (assumed to be a mapping node)

func GetNode

func GetNode(root *yaml.Node, key *YamlIndex) (*yaml.Node, error)

GetNode returns the node that contains the content for the key TODO support indexes

func HasKeyValue

func HasKeyValue(node *yaml.Node, key string, values ...string) (bool, error)

HasKeyValue checks if the node (assumed to be a mapping node) has a key with the given value(s). If many values, any is ok. If it does not, (false, nil) is returned. If there is an error, like a key not existing, an error is returned.

func HasNode

func HasNode(root *yaml.Node, key *YamlIndex) bool

HasNode returns true if the root node has the key

func Iterate

func Iterate(root *yaml.Node, callable func(parent, value *yaml.Node))

Iterate runs through all of the content nodes in the indicated root node

func SetKeyValue

func SetKeyValue(node *yaml.Node, key string, value string) error

SetKeyValue set's the content node's value to value for the indicated key

Types

type NodePair

type NodePair struct {
	Key   *yaml.Node
	Value *yaml.Node
}

NodePair is a convenience wrapper for two nodes, usually a key/value pair.

type YamlIndex

type YamlIndex struct {
	// contains filtered or unexported fields
}

YamlIndex identifies a path in a Yaml Node Tree

func CreateYamlIndex

func CreateYamlIndex(parts ...string) *YamlIndex

CreateYamlIndex creates a YamlIndex that specifies the Key via string parts. e.g. a key maybe be: parent.child.favoriteNumber and the returned YamlIndex would reflect this. Note: this does not yet support indexing array values.

func (*YamlIndex) String

func (y *YamlIndex) String() string

String returns the YamlIndex indicated by the parts separated by "." e.g. parent.children.favoriteNumber

Jump to

Keyboard shortcuts

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