Documentation ¶
Index ¶
- func Marshal(value interface{}) ([]byte, error)
- func Unmarshal(in []byte, out interface{}) error
- func UnmarshalMap(unmarshal func(interface{}) error) (map[string]interface{}, error)
- type Editor
- func (e *Editor) DeleteNode(path string) error
- func (e *Editor) GetNode(path string) (*yaml.Node, error)
- func (e *Editor) GetValue(path string) (string, error)
- func (e *Editor) Read(data []byte) (n int, err error)
- func (e *Editor) ReadFile(src string) error
- func (e *Editor) SetValue(path string, value string) error
- func (e *Editor) WalkNodes(ctx context.Context, path string, ...) error
- func (e *Editor) WriteFile(dest string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarshalMap ¶
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 (*Editor) DeleteNode ¶ added in v1.0.1
func (*Editor) GetNode ¶ added in v1.0.1
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) 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.