Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrModelineNotFound = errors.New("modeline not found")
ErrModelineNotFound is the sentinel cause FindAndParseModeline returns (wrapped with a hint) when the input file has no `# talm: …` line at all. Distinct from "found but malformed": callers route the not-found case onto a different path (e.g. direct-patch in apply, "this isn't a modelined node file" in completion) while malformed-modeline errors bubble up so the operator sees their typo. Match with errors.Is.
Functions ¶
func GenerateModeline ¶
GenerateModeline creates a modeline string using JSON formatting for values.
Types ¶
type Config ¶
Config structure for storing settings from modeline.
func FindAndParseModeline ¶ added in v0.29.0
FindAndParseModeline scans a file for the talm modeline, allowing operator-authored comment lines (`^#`) and blank lines as a leading prefix. The first non-comment, non-blank line must be the modeline itself (`# talm: …`); arbitrary YAML or prose before the modeline is rejected.
Returns the leading comment / blank lines verbatim (without trailing `\n`), the parsed Config, and any error. `talm template -I` uses the leading-lines return to preserve operator documentation when the in-place rewrite overwrites the file. Every other talm workflow that consumes node files (apply, upgrade, completion, wrapped talosctl commands) calls this function too so the file-shape contract is uniform across the surface.
func ParseModeline ¶
ParseModeline parses a modeline string and populates the Config structure.