manifest

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(doc *yaml.Node) (string, error)

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

func MapValue(m *yaml.Node, key string) *yaml.Node

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(node *yaml.Node, keys ...string) *yaml.Node

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

func Rebuild(content string, spans []DocSpan, edits map[int]string) string

Rebuild reassembles a file, replacing only the documents named in edits and copying everything else — separators and untouched documents alike — verbatim.

func SetMapValue

func SetMapValue(m *yaml.Node, key string, value *yaml.Node)

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

func SetStringScalar(m *yaml.Node, key, value string)

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.

Types

type DocSpan

type DocSpan struct {
	Start, End int
	Kind, Name string
}

DocSpan is one YAML document's byte span within a file, plus its kind and metadata.name.

func Classify

func Classify(content string) []DocSpan

Classify splits content into document spans, tagging each with its kind and metadata.name. An empty or unparseable segment stays untagged, so it never matches a workload.

Jump to

Keyboard shortcuts

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