config

package
v0.0.11 Latest Latest
Warning

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

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

Documentation

Overview

Package config defines the provisioning configuration provider interface.

Index

Constants

View Source
const (
	DefaultCrashArtifactsMaxMB            = 256
	DefaultCrashArtifactsUploadTimeoutSec = 120
)

Crash artifact collection defaults.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	ID      string
	Type    string
	Payload []byte
}

Command represents a server-issued command (future agent mode).

type LVMConfig added in v0.0.8

type LVMConfig struct {
	VolumeGroup string     `json:"volumeGroup"` // VG name (e.g. "sysvg")
	PVPartition int        `json:"pvPartition"` // 1-based partition index for the PV
	Volumes     []LVVolume `json:"volumes"`     // Logical volumes to create
}

LVMConfig defines LVM volume group and logical volume configuration.

type LVVolume added in v0.0.8

type LVVolume struct {
	Name       string `json:"name"`                 // LV name (e.g. "root", "var")
	SizeMB     int    `json:"sizeMB,omitempty"`     // Size in MiB (0 = fill remaining)
	Extents    string `json:"extents,omitempty"`    // Size as extents (e.g. "100%FREE")
	Filesystem string `json:"filesystem,omitempty"` // mkfs type
	Mountpoint string `json:"mountpoint,omitempty"` // Target mount path
}

LVVolume defines a single logical volume within an LVM volume group.

type MachineConfig

type MachineConfig struct {
	ImageURLs         []string // Space-separated IMAGE field from /deploy/vars
	ImageChecksum     string   // IMAGE_CHECKSUM: expected hex digest of the raw image
	ImageChecksumType string   // IMAGE_CHECKSUM_TYPE: "sha256" or "sha512"
	ImageMode         string   // IMAGE_MODE: "whole-disk" (default) or "partition" for partition-by-partition
	Hostname          string   // HOSTNAME
	Token             string   // TOKEN (Bearer auth for CAPRF server)
	ExtraKernelParams string   // MACHINE_EXTRA_KERNEL_PARAMS
	FailureDomain     string   // FAILURE_DOMAIN (topology.kubernetes.io/zone)
	Region            string   // REGION
	ProviderID        string   // PROVIDER_ID (kubelet --provider-id)
	Mode              string   // MODE: "provision", "deprovision", "soft-deprovision"
	MinDiskSizeGB     int      // MIN_DISK_SIZE_GB (optional, 0 = no minimum)
	DiskDevice        string   // DISK_DEVICE: override disk detection (e.g. "/dev/sda", "/dev/loop0")
	NumVFs            int      // NUM_VFS: number of SR-IOV VFs for Mellanox (default: 32)
	DisableKexec      bool     // DISABLE_KEXEC: skip kexec and always hard-reboot
	SecureErase       bool     // SECURE_ERASE: use ATA/NVMe secure erase instead of wipefs
	PostProvisionCmds []string // POST_PROVISION_CMDS: commands to run in chroot after provisioning

	// Image verification fields.
	ImageSignatureURL string // IMAGE_SIGNATURE_URL: detached GPG signature URL
	ImageGPGPubKey    string // IMAGE_GPG_PUBKEY: path to GPG public key for image verification

	// Status URLs parsed from /deploy/vars.
	LogURL       string
	InitURL      string
	ErrorURL     string
	SuccessURL   string
	DebugURL     string
	HeartbeatURL string // POST /status/heartbeat
	CommandsURL  string // GET /commands

	// Network configuration (from kernel cmdline or /deploy/vars).
	UnderlaySubnet   string // underlay_subnet: e.g. "192.168.4.0/24"
	UnderlayIP       string // underlay_ip: direct underlay loopback IP
	OverlaySubnet    string // overlay_subnet: e.g. "2a01:598:40a:5481::/64"
	IPMISubnet       string // ipmi_subnet: e.g. "172.30.0.0/24"
	ASN              uint32 // asn_server: BGP AS number
	ProvisionVNI     uint32 // provision_vni: VXLAN VNI
	ProvisionIP      string // provision_ip: IP/mask for provision bridge
	ProvisionGateway string // provision_gateway: gateway VTEP IP for BUM flooding
	DNSResolvers     string // dns_resolver: comma-separated DNS servers
	DCGWIPs          string // dcgw_ips: Data Center Gateway IPs (onefabric)
	LeafASN          uint32 // leaf_asn: Leaf switch AS
	LocalASN         uint32 // local_asn: Local AS for leaf connections
	OverlayAggregate string // overlay_aggregate: route aggregate for overlay
	VPNRT            string // vpn_rt: VPN route target for EVPN

	// Static networking fields.
	StaticIP      string // STATIC_IP: IP/mask to assign (e.g. "10.0.0.5/24")
	StaticGateway string // STATIC_GATEWAY: default gateway IP
	StaticIface   string // STATIC_IFACE: interface name (default: auto-detect first physical NIC)

	// BGP/BFD tuning fields.
	VRFTableID    uint32 // vrf_table_id: routing table ID for VRF (default: 1)
	BGPKeepalive  uint32 // bgp_keepalive: BGP keepalive interval in seconds (0 = FRR default)
	BGPHold       uint32 // bgp_hold: BGP hold timer in seconds (0 = FRR default)
	BFDTransmitMS uint32 // bfd_transmit_ms: BFD transmit interval in ms (default: 300)
	BFDReceiveMS  uint32 // bfd_receive_ms: BFD receive interval in ms (default: 300)

	// Firmware reporting fields.
	FirmwareEnabled bool   // FIRMWARE_REPORT: enable firmware collection
	FirmwareURL     string // FIRMWARE_URL: endpoint for firmware report
	FirmwareMinBIOS string // FIRMWARE_MIN_BIOS: minimum BIOS version
	FirmwareMinBMC  string // FIRMWARE_MIN_BMC: minimum BMC version

	// LACP bonding fields.
	BondInterfaces string // BOND_INTERFACES: comma-separated NICs to bond (e.g. "eth0,eth1")
	BondMode       string // BOND_MODE: bonding mode (default: "802.3ad")

	// VLAN fields.
	VLANs string // VLANS: multi-VLAN config "200:eno1:10.200.0.42/24,300:eno2"

	// Hardware inventory fields.
	InventoryEnabled bool   // INVENTORY_ENABLED: collect and report hardware inventory
	InventoryURL     string // INVENTORY_URL: POST endpoint for inventory JSON

	// Health check configuration.
	HealthChecksEnabled bool   // HEALTH_CHECKS_ENABLED: run pre-provision health checks
	HealthMinMemoryGB   int    // HEALTH_MIN_MEMORY_GB: minimum RAM in GiB (name kept for compatibility)
	HealthMinCPUs       int    // HEALTH_MIN_CPUS: minimum CPU count
	HealthSkipChecks    string // HEALTH_SKIP_CHECKS: comma-separated check names to skip
	HealthCheckURL      string // HEALTH_CHECK_URL: POST endpoint for health results

	// BGP peering mode and numbered peer configuration.
	BGPPeerMode     string // BGP_PEER_MODE: "unnumbered" (default), "dual", "numbered"
	BGPNeighbors    string // BGP_NEIGHBORS: comma-separated numbered peer IPs
	BGPRemoteASN    uint32 // bgp_remote_asn: remote ASN for numbered peers (0 = iBGP)
	BGPUnderlayAF   string // BGP_UNDERLAY_AF: underlay address family (ipv4/ipv6/dual-stack)
	BGPOverlayType  string // BGP_OVERLAY_TYPE: overlay encapsulation (evpn-vxlan/l3vpn/none)
	BGPAuthPassword string // BGP_AUTH_PASSWORD: optional TCP-MD5 password for all BGP peers

	// Dry-run mode.
	DryRun bool // DRY_RUN: simulate provisioning without destructive changes

	// Transport security override (testing only).
	InsecureTransport bool // INSECURE_TRANSPORT: allow bearer tokens over plain HTTP (testing only)

	// Network mode override.
	NetworkMode string // NETWORK_MODE: "gobgp" to use in-process GoBGP instead of FRR

	// Telemetry configuration.
	TelemetryEnabled bool   // TELEMETRY_ENABLED: enable provisioning metrics collection
	TelemetryURL     string // TELEMETRY_URL: POST endpoint for metrics snapshot

	// Observability fields.
	MetricsURL string // METRICS_URL: POST endpoint for provisioning metrics
	EventURL   string // EVENT_URL: POST endpoint for provisioning events

	// Startup crash artifact collection.
	CrashArtifactsEnabled          bool   // CRASH_ARTIFACTS_ENABLED: inspect existing OS for crash artifacts before destructive actions
	CrashArtifactsPrepareURL       string // CRASH_ARTIFACTS_PREPARE_URL: CAPRF endpoint that returns upload instructions
	CrashArtifactsUploadURL        string // CRASH_ARTIFACTS_UPLOAD_URL: direct CAPRF proxy upload endpoint
	CrashArtifactsMaxMB            int    // CRASH_ARTIFACTS_MAX_MB: max archive payload in MiB (0 = default)
	CrashArtifactsUploadTimeoutSec int    // CRASH_ARTIFACTS_UPLOAD_TIMEOUT_SEC: upload timeout seconds (0 = default)

	// SecureBoot lifecycle fields.
	SecureBootReEnable bool   // SECUREBOOT_REENABLE: signal CAPRF to re-enable SecureBoot after provisioning
	MOKCertPath        string // MOK_CERT_PATH: path to DER-encoded MOK certificate for enrollment
	MOKPassword        string // MOK_PASSWORD: one-time password for MokManager confirmation

	// Rescue mode configuration.
	RescueMode           string // RESCUE_MODE: "reboot" (default), "retry", "shell", "wait"
	RescueSSHPubKey      string // RESCUE_SSH_PUBKEY: authorized SSH public key for rescue shell
	RescuePasswordHash   string // RESCUE_PASSWORD_HASH: crypt(3) password hash for rescue shell
	RescueTimeout        int    // RESCUE_TIMEOUT: seconds before rescue auto-action, 0 = infinite
	RescueAutoMountDisks bool   // RESCUE_AUTO_MOUNT: auto-mount discovered disks in rescue mode

	// EVPN L2 overlay (Type-2/3 route processing) — disabled by default.
	EVPNL2Enabled bool // EVPN_L2_ENABLED: enable Type-2/3 route handling for L2 overlay

	// Cloud-init generation.
	CloudInitEnabled    bool   // CLOUDINIT_ENABLED: generate and inject cloud-init config
	CloudInitDatasource string // CLOUDINIT_DATASOURCE: datasource type (defaults to "nocloud" if empty)

	// NVMe namespace management.
	NVMeNamespaces string // NVME_NAMESPACES: JSON config for namespace creation

	// Files and commands from ISO /deploy/ directories.
	ProvisionerFiles []string // Paths to files in /deploy/file-system/
	MachineFiles     []string // Paths to files in /deploy/machine-files/
	MachineCommands  []string // Commands from /deploy/machine-commands/

	// Declarative disk partitioning (JSON from PARTITION_LAYOUT).
	PartitionLayout *PartitionLayout

	// JWT token management.
	TokenURL       string // TOKEN_URL: JWT token endpoint
	TokenAlgorithm string // TOKEN_ALGORITHM: RS256 or ES256
}

MachineConfig holds all configuration needed for provisioning a machine.

func (*MachineConfig) Validate added in v0.0.8

func (c *MachineConfig) Validate() error

Validate checks that enum-like config fields contain known values. Empty strings are accepted (will use defaults downstream).

type Partition added in v0.0.8

type Partition struct {
	Label      string `json:"label"`                // GPT partition label (e.g. "efi", "root", "data")
	SizeMB     int    `json:"sizeMB,omitempty"`     // Size in MiB (0 = fill remaining space)
	TypeGUID   string `json:"typeGUID,omitempty"`   // GPT type GUID (auto-set from fsType if omitted)
	Filesystem string `json:"filesystem,omitempty"` // mkfs type: "vfat", "ext4", "xfs", "swap"
	Mountpoint string `json:"mountpoint,omitempty"` // Target mount path (e.g. "/", "/boot/efi")
}

Partition defines a single partition in a PartitionLayout.

type PartitionLayout added in v0.0.8

type PartitionLayout struct {
	Table      string      `json:"table"`            // "gpt" (default: "gpt") — only GPT is supported
	Device     string      `json:"device,omitempty"` // Device override (empty = auto-detect)
	Partitions []Partition `json:"partitions"`       // Ordered list of partitions to create
	LVM        *LVMConfig  `json:"lvm,omitempty"`    // Optional LVM configuration
}

PartitionLayout defines a declarative partitioning scheme for the target disk.

func ParsePartitionLayout added in v0.0.8

func ParsePartitionLayout(data string) (*PartitionLayout, error)

ParsePartitionLayout parses a JSON partition layout string.

type Provider

type Provider interface {
	// GetConfig fetches machine configuration.
	GetConfig(ctx context.Context) (*MachineConfig, error)
	// ReportStatus sends provisioning status to the server.
	ReportStatus(ctx context.Context, status Status, message string) error
	// ShipLog sends a log line to the server.
	ShipLog(ctx context.Context, message string) error
	// Heartbeat sends a keepalive signal (no-op in current mode, future agent mode).
	Heartbeat(ctx context.Context) error
	// FetchCommands retrieves pending commands (nil in current mode, future agent mode).
	FetchCommands(ctx context.Context) ([]Command, error)
	// AcknowledgeCommand reports command execution result back to the server.
	AcknowledgeCommand(ctx context.Context, cmdID, status, message string) error
	// ReportInventory sends hardware inventory data to the server.
	ReportInventory(ctx context.Context, data []byte) error
	// ReportFirmware sends a firmware report to the server.
	ReportFirmware(ctx context.Context, data []byte) error
}

Provider abstracts provisioning server communication.

type Status

type Status string

Status represents the provisioning status reported to the server.

const (
	StatusInit    Status = "init"
	StatusSuccess Status = "success"
	StatusError   Status = "error"
)

Provisioning status constants.

Jump to

Keyboard shortcuts

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