Documentation ¶
Index ¶
- Variables
- func Clone(node *yaml.Node) *yaml.Node
- func Compare(yaml1, yaml2 []byte) bool
- func EqualWithExclusion(a, b *yaml.Node, excludedPath ...string) bool
- func FindNode(node *yaml.Node, path string) (resultNode *yaml.Node, err error)
- func FindNodeValueOrDefault(node *yaml.Node, path string, defaultValue string) string
- func HasLockedTodos(node *yaml.Node) bool
- func Merge(dst, src *yaml.Node) *yaml.Node
- func SetOrAddNodeValue(node *yaml.Node, path string, value string) error
- func TreeToYaml(tree *yaml.Node, indent int) (string, error)
- type File
- type KeyValuePair
- type Writer
- type WriterMock
Constants ¶
This section is empty.
Variables ¶
View Source
var CustomTags = []string{"!lock", "!local"}
View Source
var DiskWriter = writerFunc(func(file *File) error { return os.WriteFile(file.Path, file.Yaml, 0o644) })
View Source
var KnownTags = append(StandardTags, CustomTags...)
View Source
var StandardTags = []string{
"",
"!!int",
"!!bool",
"!!float",
"!!map",
"!!str",
"!!seq",
"!!null",
}
Functions ¶
func Compare ¶
Compare returns true if the two yaml documents are equivalent in terms of contents and comments, false otherwise, disregarding differences in formatting / whitespace.
func EqualWithExclusion ¶ added in v0.21.0
func FindNode ¶
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 HasLockedTodos ¶ added in v0.51.0
func HasLockedTodos(node *yaml.Node) bool
func SetOrAddNodeValue ¶
func TreeToYaml ¶
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 NewFileFromObject ¶ added in v0.46.2
func NewFileFromTree ¶
func (*File) CopyWithNewTree ¶
func (*File) UpdateYamlFromTree ¶
type KeyValuePair ¶ added in v0.20.2
type KeyValuePair struct { Key *yaml.Node Value *yaml.Node }
type WriterMock ¶ added in v0.39.0
type WriterMock struct { // WriteFileFunc mocks the WriteFile method. WriteFileFunc func(file *File) error // contains filtered or unexported fields }
WriterMock is a mock implementation of Writer.
func TestSomethingThatUsesWriter(t *testing.T) { // make and configure a mocked Writer mockedWriter := &WriterMock{ WriteFileFunc: func(file *File) error { panic("mock out the WriteFile method") }, } // use mockedWriter in code that requires Writer // and then make assertions. }
func (*WriterMock) WriteFile ¶ added in v0.39.0
func (mock *WriterMock) WriteFile(file *File) error
WriteFile calls WriteFileFunc.
func (*WriterMock) WriteFileCalls ¶ added in v0.39.0
func (mock *WriterMock) WriteFileCalls() []struct { File *File }
WriteFileCalls gets all the calls that were made to WriteFile. Check the length with:
len(mockedWriter.WriteFileCalls())
Click to show internal directories.
Click to hide internal directories.