bootstrapspec

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bootstrapspec is the ONE reader of spec.bootstrap entries. The bootstrap engine, `lo lint` and `lo audit` all resolve and parse entries through it, so the three never disagree on what an entry means (bash: bootstrap::_resolve_entries and bootstrap::_parse_entry in .lok8s/libs/bootstrap, which lint and audit call as well).

Entry forms:

scalar  "cilium" | "./targets/x" | "/abs/x"   → name/dir only
map     {"<name-or-path>": <value>}

The map VALUE is read in one of two schemas: NEW (carries a reserved key values | valueFiles | env | wait | dependsOn | name) or LEGACY (no reserved key → the WHOLE value map IS the inline helm values).

The package validates and resolves. What differs per caller stays with the caller: the error channel (Parser.Report: printed by the engine and the linter, silent in the audit) and the valueFiles merge (Parser.MergeValueFiles: the engine merges to a YAML string, the audit to a node, the linter only checks that each file parses). The validation order and every message are the bash ones.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactJSON

func CompactJSON(n *yaml.Node) string

CompactJSON renders a node the way `yq -o=json -I=0` does: strings JSON-escaped without HTML escaping, numbers/bools verbatim, objects and arrays compact and in document order. The rendering is part of the error-message contract (the entry JSON appears in the "entry not found" and "single-key map" messages).

Types

type Entry

type Entry struct {
	// Raw is the compact-JSON entry as resolved (used verbatim in the
	// "addon not found" error, like bash's ${entry}).
	Raw string
	// Key is the <name-or-path> as written (bash: _raw).
	Key string
	// Name is the entry identity: basename / map-key, or the explicit
	// `name:` override.
	Name string
	// Dir is the resolved addon directory (never changed by `name:`).
	Dir string
	// Explicit reports whether Name came from an explicit `name:` override
	// (a name collision on it is a hard error, not a tolerated clash).
	Explicit bool
	// Builtin reports a bare framework-addon entry (Dir resolved through
	// internal/assets: the project's .lok8s/addons/<name> when present, else
	// the copy embedded in the binary) as opposed to a cluster-local target
	// or an absolute path.
	Builtin bool
	// Legacy is the whole-map-is-helm-values shim: Value is the inline
	// helm values.
	Legacy bool
	// Value is the map value (nil for a scalar entry or a null value).
	Value *yaml.Node
	// Values is the `values:` node, nil when the key is absent (a present
	// key with a null value is a null node).
	Values *yaml.Node
	// ValueFiles are the `valueFiles:` paths, resolved against the cluster
	// dir; every one exists.
	ValueFiles []string
	// Env are the `env:` KEY=tostring(value) pairs, in map order (an empty
	// key is dropped).
	Env []EnvVar
	// Wait marks a global barrier gate (`wait: true`).
	Wait bool
	// Deps are the dependsOn entry names, in order.
	Deps []string
	// contains filtered or unexported fields
}

Entry is one parsed entry (bash: the out-params of bootstrap::_parse_entry).

type EnvVar

type EnvVar struct {
	Key   string
	Value string
}

EnvVar is one env: override.

type Item

type Item struct {
	Raw  string
	Node *yaml.Node
}

Item is one resolved spec.bootstrap entry: the node, and its compact JSON rendering (bash: `yq -o=json -I=0`), which IS part of the error messages. The per-driver default is the BARE word cilium (bash: echo), so its Raw carries no quotes.

func Resolve

func Resolve(root *yaml.Node, kind string) []Item

Resolve lists the entries to apply for a spec document (bash: bootstrap::_resolve_entries). Three cases:

  • explicit non-empty spec.bootstrap → exactly those entries, in order (`.spec.bootstrap[]?`: the items of a sequence, the VALUES of a map)
  • explicit empty `bootstrap: []` → nothing (authoritative opt-out)
  • absent spec.bootstrap → per-driver default

The default is per-driver, NOT one-size-fits-all: only `lo` (kind) ships without a CNI and must have one bootstrapped. KubeOne deploys its own cilium during `kubeone apply`; Capi/Kkp clusters bring their CNI from the management cluster / addon set. Defaulting those to [cilium] caused a stray cilium apply on managed clusters.

type Parser

type Parser struct {
	Paths *config.Paths
	// Report receives each validation failure as a printf pair (the bash
	// error() text, without the [error] prefix). nil = silent.
	Report func(format string, a ...any)
	// MergeValueFiles runs at the point bash merged valueFiles (files in
	// list order, the inline `values:` on top). values is the `values:`
	// node, nil when absent. A non-nil error fails the entry with the bash
	// "failed to merge" message. nil = no merge.
	MergeValueFiles func(files []string, values *yaml.Node) error
}

Parser parses entries for one caller.

func (*Parser) Parse

func (p *Parser) Parse(domain string, item Item) (e *Entry, ok bool)

Parse parses ONE entry (bash: bootstrap::_parse_entry). ok=false after reporting the failure. Pure apart from the filesystem touches bash made (the chart.yaml check, the valueFiles stat, the addon peek).

Jump to

Keyboard shortcuts

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