gen

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package gen turns an extract.Manifest into a Go struct source file: one field per resolved, non-alias flag, tagged with the flag's real kebab-case name as its yaml key. See docs/agent/design-config-codegen.md -- the flag name, not the Go field name, is the source of truth for what a valid config.yaml key looks like.

Index

Constants

This section is empty.

Variables

View Source
var Registry = map[string]map[string]Entry{
	"k3s": {
		"v1_31": {Server: k3s_v1_31.ServerConfig{}, Agent: k3s_v1_31.AgentConfig{}},
		"v1_32": {Server: k3s_v1_32.ServerConfig{}, Agent: k3s_v1_32.AgentConfig{}},
		"v1_33": {Server: k3s_v1_33.ServerConfig{}, Agent: k3s_v1_33.AgentConfig{}},
		"v1_34": {Server: k3s_v1_34.ServerConfig{}, Agent: k3s_v1_34.AgentConfig{}},
		"v1_35": {Server: k3s_v1_35.ServerConfig{}, Agent: k3s_v1_35.AgentConfig{}},
		"v1_36": {Server: k3s_v1_36.ServerConfig{}, Agent: k3s_v1_36.AgentConfig{}},
	},
	"rke2": {
		"v1_31": {Server: rke2_v1_31.ServerConfig{}, Agent: rke2_v1_31.AgentConfig{}},
		"v1_32": {Server: rke2_v1_32.ServerConfig{}, Agent: rke2_v1_32.AgentConfig{}},
		"v1_33": {Server: rke2_v1_33.ServerConfig{}, Agent: rke2_v1_33.AgentConfig{}},
		"v1_34": {Server: rke2_v1_34.ServerConfig{}, Agent: rke2_v1_34.AgentConfig{}},
		"v1_35": {Server: rke2_v1_35.ServerConfig{}, Agent: rke2_v1_35.AgentConfig{}},
		"v1_36": {Server: rke2_v1_36.ServerConfig{}, Agent: rke2_v1_36.AgentConfig{}},
	},
}

Registry maps distro id (e.g. "k3s", "rke2") -> sanitized minor version package name (e.g. "v1_35") -> Entry. See Lookup in lookup.go for the consumer-facing API.

Functions

func Generate

func Generate(opts Options) ([]byte, error)

Generate renders and gofmt's the struct source for opts.Manifest.

func Keys

func Keys(v any) map[string]struct{}

Keys returns the set of yaml key names declared on a generated config struct (an Entry's Server or Agent field), derived from each field's `yaml:"name,omitempty"` tag.

Types

type Entry

type Entry struct {
	Server any
	Agent  any
}

Entry holds the zero-value generated Server/Agent config structs for one distro/version, as produced by mage generate:engineConfig. Registry (in the generated zz_registry.go) is keyed by distro id and minor-version package name (e.g. "v1_35").

func Lookup

func Lookup(distroID, version string) (Entry, bool)

Lookup returns the Entry registered for distroID (e.g. "k3s", "rke2") and an engine version string in any format containing a dotted major.minor (e.g. "1.35.3-k3s1", "v1.35.3+k3s1"). The version is truncated to its minor release before lookup, the same way mage generate:pullEngineSource truncates upstream tags before pulling source -- so a single generated version covers every patch release in that minor line. Reports false if no source was ever pulled/generated for that distro/minor-version pair.

type Options

type Options struct {
	PackageName string // must already be a valid Go package identifier
	StructName  string
	Manifest    extract.Manifest
}

Options configures one generated struct file.

Directories

Path Synopsis
k3s
rke2

Jump to

Keyboard shortcuts

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