Documentation
¶
Index ¶
- func RenameYamlKey(yamlBytes []byte, path []string, newKey string) ([]byte, error)
- func TransformNode(yamlBytes []byte, path []string, transform func(node *yaml.Node) (bool, error)) ([]byte, error)
- func UpdateYamlValue(yamlBytes []byte, path []string, value string) ([]byte, error)
- func Walk(yamlBytes []byte, callback func(node *yaml.Node, path string) bool) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenameYamlKey ¶
takes a yaml document in bytes, 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(yamlBytes []byte, path []string, transform func(node *yaml.Node) (bool, error)) ([]byte, error)
Walks a yaml document to the specified path, and then applies the transformation to that node.
The transform must return true if it made changes to the node. If the requested path is not defined in the document, no changes are made to the document.
If no changes are made, the original document is returned. If changes are made, a newly marshalled document is returned. (This may result in different indentation for all nodes)
func UpdateYamlValue ¶
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
Traverses a yaml document, calling the callback function for each node. The callback is allowed to modify the node in place, in which case it should return true. The function returns the original yaml document if none of the callbacks returned true, and the modified document otherwise.
Types ¶
This section is empty.