yamlnode

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyValue added in v0.2.0

func KeyValue(node *yaml.Node) iter.Seq2[*yaml.Node, *yaml.Node]

KeyValue iterates over a yaml.MappingNode kinda like a map[*yaml.Node]*yaml.Node It iterates multiple content elements in yaml.DocumentNode and will follow yaml.AliasNode.

func Keys

func Keys(node *yaml.Node) iter.Seq[*yaml.Node]

Keys returns the keys of a yaml.MappingNode. It uses KeyValue and will iterate yaml.DocumentNode and yaml.AliasNode.

func LookupKey

func LookupKey(node *yaml.Node, key string) (*yaml.Node, bool)

LookupKey does a simple lookup of a string key in a yaml.MappingNode it does not support recursive lookup, or any other fancy features. Consider using Walk or github.com/mikefarah/yq/v3/pkg/yqlib for more sophisticated queries.

func LookupValueFunc added in v0.2.0

func LookupValueFunc(node *yaml.Node, checkKey func(n *yaml.Node) bool) (*yaml.Node, bool)

LookupValueFunc does a simple lookup of a node in a yaml.MappingNode It does not support recursive lookup, or any other fancy features. It uses KeyValue and will iterate yaml.DocumentNode and yaml.AliasNode.

func ValuesStrings

func ValuesStrings(nodes []*yaml.Node) iter.Seq[string]

ValuesStrings returns the Value fields from a yaml.Node of a list of nodes.

func Walk

func Walk(node *yaml.Node, fn func(node *yaml.Node) error, kinds yaml.Kind) error

Walk walks a yaml.Node tree, calling fn on each node. If fn returns an error, Walk returns that error and stops walking. Aliases are followed and may cause an infinite loop.

Types

type WithDataType

type WithDataType[T any] struct {
	Data T
	Node *yaml.Node
}

WithDataType is a wrapper for a yaml.Node that also stores the decoded value. It is useful when you want to reflect back on the original yaml.Node after parsing. This may be helpful for providing richer error messages for configuration problems.

func (WithDataType[T]) MarshalYAML

func (wt WithDataType[T]) MarshalYAML() (any, error)

func (*WithDataType[T]) UnmarshalYAML

func (wt *WithDataType[T]) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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