Documentation
¶
Overview ¶
Package manifest mutates Kubernetes GitOps manifests by editing a structured YAML document model, never by splicing strings into manifest text: only the matched document is re-encoded, so its siblings survive byte-for-byte.
It operates on manifest text and yaml.Node values alone, so each manifest.* Function layers its own inputs, validation, and matching policy on top.
Index ¶
- func Encode(doc *yaml.Node) (string, error)
- func FindDocument(spansByFile [][]DocSpan, kinds map[string]bool, name string) (fileIdx, segIdx, count int)
- func MapValue(m *yaml.Node, key string) *yaml.Node
- func Navigate(node *yaml.Node, keys ...string) *yaml.Node
- func Rebuild(content string, spans []DocSpan, edits map[int]string) string
- func SetMapValue(m *yaml.Node, key string, value *yaml.Node)
- func SetStringScalar(m *yaml.Node, key, value string)
- type DocSpan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode serializes a single-document yaml.Node at the source document's indentation (see detectIndent). yaml.v3 normalizes some cosmetic formatting on the re-encoded document; the byte-for-byte guarantee is for its siblings.
func FindDocument ¶
func FindDocument(spansByFile [][]DocSpan, kinds map[string]bool, name string) (fileIdx, segIdx, count int)
FindDocument locates the single document across a file set whose kind is in kinds and whose metadata.name equals name, along with how many matched. When count != 1 the indices are unspecified and must not be used.
func MapValue ¶
MapValue returns the value node for key in a mapping node, or nil. A yaml.v3 mapping node stores keys and values as alternating Content entries.
func Navigate ¶
Navigate walks a chain of mapping keys from node, returning the value node at the end or nil if any hop is missing or isn't a mapping.
func Rebuild ¶
Rebuild reassembles a file, replacing only the documents named in edits and copying everything else — separators and untouched documents alike — verbatim.
func SetMapValue ¶
SetMapValue sets key in mapping m to value, replacing the whole value node rather than editing it in place as SetStringScalar does, so it can set or replace a nested subtree such as spec.strategy.
func SetStringScalar ¶
SetStringScalar sets key in mapping m to a literal string scalar, adding the key if it's absent. Resetting Kind/Tag/Style/Anchor/Alias on an existing value node is what keeps a crafted value data rather than structure.