config

package
v0.0.0-...-0d3b17f Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config parses and validates nova.hcl configuration files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Variables    []Variable    `hcl:"variable,block"`
	VM           *VM           `hcl:"vm,block"`
	Defaults     *Defaults     `hcl:"defaults,block"`
	Nodes        []Node        `hcl:"node,block"`
	Network      *Network      `hcl:"network,block"`
	Links        []Link        `hcl:"link,block"`
	Provisioners []Provisioner `hcl:"provisioner,block"`
	User         *User         `hcl:"user,block"`
}

Config is the top-level representation of a nova.hcl file. It supports both single-VM mode (a single "vm" block) and multi-node mode (one or more "node" blocks). If both are present, parsing returns an error.

func Load

func Load(path string) (*Config, error)

Load parses an HCL file at the given path, resolves variables, and returns a validated Config.

func Parse

func Parse(src []byte, filename string) (*Config, error)

Parse parses HCL source bytes into a validated Config.

func (*Config) ResolveNodes

func (c *Config) ResolveNodes() []ResolvedNode

ResolveNodes returns the list of fully-resolved nodes from the config. For single-VM configs, it returns a single node derived from the VM block.

func (*Config) Subnet

func (c *Config) Subnet() string

Subnet returns the configured cluster subnet, or a default.

type Defaults

type Defaults struct {
	Image  string `hcl:"image,optional"`
	CPUs   int    `hcl:"cpus,optional"`
	Memory string `hcl:"memory,optional"`
	DiskGB int    `hcl:"disk_gb,optional"`
	Arch   string `hcl:"arch,optional"`
}

Defaults holds global default values that nodes inherit.

type Link struct {
	NodeA   string `hcl:"node_a,label"`
	NodeB   string `hcl:"node_b,label"`
	Latency string `hcl:"latency,optional"` // e.g. "50ms"
	Jitter  string `hcl:"jitter,optional"`  // e.g. "10ms"
	Loss    string `hcl:"loss,optional"`    // e.g. "5%"
	Down    bool   `hcl:"down,optional"`    // Hard partition.
}

Link defines declarative network conditions between two nodes.

type Network

type Network struct {
	Subnet string `hcl:"subnet,optional"` // e.g. "10.0.0.0/24"
}

Network configures the virtual network for multi-node clusters.

type Node

type Node struct {
	Name          string         `hcl:"name,label"`
	Image         string         `hcl:"image,optional"`
	CPUs          int            `hcl:"cpus,optional"`
	Memory        string         `hcl:"memory,optional"`
	DiskGB        int            `hcl:"disk_gb,optional"`
	Arch          string         `hcl:"arch,optional"`
	IP            string         `hcl:"ip,optional"`
	PortForwards  []PortForward  `hcl:"port_forward,block"`
	SharedFolders []SharedFolder `hcl:"shared_folder,block"`
	Provisioners  []Provisioner  `hcl:"provisioner,block"`
	User          *User          `hcl:"user,block"`
}

Node describes a single node in a multi-node configuration.

type PortForward

type PortForward struct {
	Host     int    `hcl:"host"`
	Guest    int    `hcl:"guest"`
	Protocol string `hcl:"protocol,optional"`
}

PortForward maps a host port to a guest port.

type Provisioner

type Provisioner struct {
	Type    string            `hcl:"type,label"`
	Script  string            `hcl:"script,optional"`
	Inline  []string          `hcl:"inline,optional"`
	Timeout string            `hcl:"timeout,optional"`
	Env     map[string]string `hcl:"env,optional"`
}

Provisioner describes a provisioning step to run after VM boot. The label must be "shell" (the only supported provisioner type for now).

type ResolvedNode

type ResolvedNode struct {
	Name          string
	Image         string
	CPUs          int
	Memory        string
	DiskGB        int
	Arch          string
	IP            string
	PortForwards  []PortForward
	SharedFolders []SharedFolder
	Provisioners  []Provisioner
	User          *User
}

ResolvedNode is a fully-resolved node with all defaults applied. Used by the orchestrator so it doesn't need to know about inheritance.

type SharedFolder

type SharedFolder struct {
	HostPath  string `hcl:"host_path"`
	GuestPath string `hcl:"guest_path"`
	ReadOnly  bool   `hcl:"read_only,optional"`
}

SharedFolder mounts a host directory into the guest.

type User

type User struct {
	Name         string   `hcl:"name"`
	SSHKey       string   `hcl:"ssh_key,optional"`
	Password     string   `hcl:"password,optional"`      // plain text — Nova hashes it; enables console login
	PasswordHash string   `hcl:"password_hash,optional"` // pre-hashed (sha512crypt $6$ or bcrypt $2b$)
	Groups       []string `hcl:"groups,optional"`
	Shell        string   `hcl:"shell,optional"`
}

User describes a non-Nova user to be created in the VM. At least one of SSHKey, Password, or PasswordHash must be provided.

type VM

type VM struct {
	Name          string         `hcl:"name,optional"`
	Image         string         `hcl:"image"`
	CPUs          int            `hcl:"cpus,optional"`
	Memory        string         `hcl:"memory,optional"`
	DiskGB        int            `hcl:"disk_gb,optional"`
	Arch          string         `hcl:"arch,optional"`
	PortForwards  []PortForward  `hcl:"port_forward,block"`
	SharedFolders []SharedFolder `hcl:"shared_folder,block"`
	Provisioners  []Provisioner  `hcl:"provisioner,block"`
	User          *User          `hcl:"user,block"`
}

VM describes a single virtual machine (single-VM mode).

type Variable

type Variable struct {
	Name    string         `hcl:"name,label"`
	Default *hcl.Attribute `hcl:"default,optional"`
}

Variable defines a user-settable variable with an optional default.

Jump to

Keyboard shortcuts

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