yaml

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(value interface{}) ([]byte, error)

func Unmarshal

func Unmarshal(in []byte, out interface{}) error

func UnmarshalMap

func UnmarshalMap(unmarshal func(interface{}) error) (map[string]interface{}, error)

UnmarshalMap allows unmarshaling into types that are safe to then be marshaled to json. By default yaml serializer converts these to map[interface{}]interface which cannot be serialised as json see https://github.com/go-yaml/yaml/issues/139 This is still required even with v3 because if any key isn't parsed as a string, e.g. you have a key named 1 or 2, then the bug is still triggered.

Types

type Editor added in v1.0.1

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

Editor can modify the yaml in a Porter manifest.

func NewEditor added in v1.0.1

func NewEditor(filesystem aferox.Aferox) *Editor

func (*Editor) DeleteNode added in v1.0.1

func (e *Editor) DeleteNode(path string) error

func (*Editor) GetNode added in v1.0.1

func (e *Editor) GetNode(path string) (*yaml.Node, error)

GetNode evaluates the specified yaml path to a single node. Returns an error if a node isn't found, or more than one is found.

func (*Editor) GetValue added in v1.0.8

func (e *Editor) GetValue(path string) (string, error)

func (*Editor) Read added in v1.0.1

func (e *Editor) Read(data []byte) (n int, err error)

func (*Editor) ReadFile added in v1.0.1

func (e *Editor) ReadFile(src string) error

func (*Editor) SetValue added in v1.0.1

func (e *Editor) SetValue(path string, value string) error

func (*Editor) WalkNodes added in v1.0.1

func (e *Editor) WalkNodes(ctx context.Context, path string, f func(ctx context.Context, nc *yqlib.NodeContext) error) error

WalkNodes executes f for all yaml nodes found in path. If an error is returned from f, the WalkNodes function will return the error and stop interating through the rest of the nodes.

func (*Editor) WriteFile added in v1.0.1

func (e *Editor) WriteFile(dest string) error

Jump to

Keyboard shortcuts

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