modeline

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func GenerateModeline(nodes, endpoints, templates []string) (string, error)

GenerateModeline creates a modeline string using JSON formatting for values.

Types

type Config

type Config struct {
	Nodes     []string
	Endpoints []string
	Templates []string
}

Config structure for storing settings from modeline.

func FindAndParseModeline added in v0.29.0

func FindAndParseModeline(filePath string) ([]string, *Config, error)

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

func ParseModeline(line string) (*Config, error)

ParseModeline parses a modeline string and populates the Config structure.

Jump to

Keyboard shortcuts

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