yml

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(yaml1, yaml2 []byte) bool

Compare returns true if the two yaml documents are equivalent in terms of contents and comments, false otherwise, disregarding differences in formatting / whitespace.

func DeepCopyNode

func DeepCopyNode(node *yaml.Node) *yaml.Node

DeepCopyNode returns a deep copy of the given node.

func EncodeYaml

func EncodeYaml(obj any) ([]byte, error)

func FindNode

func FindNode(node *yaml.Node, path string) (resultNode *yaml.Node, err error)

FindNode traverses a given yaml.Node to locate the value Node of the provided path. The path is interpreted as being relative to the given yaml.Node.

func FindNodeValueOrDefault

func FindNodeValueOrDefault(node *yaml.Node, path string, defaultValue string) string

func IsCommentLocked

func IsCommentLocked(node *yaml.Node) bool

func IsKeyValueLocked

func IsKeyValueLocked(key, value *yaml.Node) bool

func IsLocked

func IsLocked(node *yaml.Node) bool

func IsTagLocked

func IsTagLocked(node *yaml.Node) bool

func Merge

func Merge(src *yaml.Node, dest *yaml.Node) *yaml.Node

Merge merges the source release into the destination release, preserving the destination release's locked values. Source and destination releases are left unchanged and a new release node tree is returned.

func SetOrAddNodeValue

func SetOrAddNodeValue(node *yaml.Node, path string, value string) error

func TreeToYaml

func TreeToYaml(tree *yaml.Node, indent int) (string, error)

Types

type File

type File struct {
	// Path is the path to the yaml file.
	Path string

	// Yaml is the raw yaml of the yaml file.
	Yaml []byte

	// Tree is the root node of the tree representation of the yaml file.
	Tree *yaml.Node

	// ApiVersion is the API version of the CRD, if any.
	ApiVersion string

	// Kind is the kind of the CRD, if any.
	Kind string

	// MetadataName is the name of the CRD resource, if any.
	MetadataName string

	// Indent is the indent size of the yaml file to be used when writing it back to disk.
	Indent int
}

File represents a yaml file loaded into memory in different forms, that can be round-tripped back to disk.

func LoadFile

func LoadFile(filePath string) (*File, error)

func NewFile

func NewFile(filePath string, content []byte) (*File, error)

func NewFileFromTree

func NewFileFromTree(filePath string, indent int, node *yaml.Node) (*File, error)

func (*File) CopyWithNewTree

func (y *File) CopyWithNewTree(newTree *yaml.Node) (*File, error)

func (*File) ToYaml

func (y *File) ToYaml() (string, error)

func (*File) UpdateYamlFromTree

func (y *File) UpdateYamlFromTree() error

func (*File) WriteYaml

func (y *File) WriteYaml() error

Jump to

Keyboard shortcuts

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