yaml_utils

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenameYamlKey

func RenameYamlKey(rootNode *yaml.Node, path []string, newKey string) error

Takes the root node of a yaml document, a path to a key, and a new name for the key. Will rename the key to the new name if it exists, and do nothing otherwise.

func TransformNode added in v0.47.0

func TransformNode(rootNode *yaml.Node, path []string, transform func(node *yaml.Node) error) error

Walks a yaml document from the root node to the specified path, and then applies the transformation to that node. If the requested path is not defined in the document, no changes are made to the document.

func UpdateYamlValue

func UpdateYamlValue(yamlBytes []byte, path []string, value string) ([]byte, error)

takes a yaml document in bytes, a path to a key, and a value to set. The value must be a scalar.

func Walk added in v0.42.0

func Walk(rootNode *yaml.Node, callback func(node *yaml.Node, path string)) error

Traverses a yaml document, calling the callback function for each node. The callback is expected to modify the node in place

func YamlMarshal added in v0.48.0

func YamlMarshal(node *yaml.Node) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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