config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// RootDir is the base directory for persistent data (images, firmware, VM DB).
	// Env: COCOON_ROOT_DIR. Default: /var/lib/cocoon.
	RootDir string `json:"root_dir" mapstructure:"root_dir"`
	// RunDir is the base directory for runtime state (PID files, Unix sockets).
	// Contents are ephemeral and may not survive reboots.
	// Env: COCOON_RUN_DIR. Default: /var/lib/cocoon/run.
	RunDir string `json:"run_dir" mapstructure:"run_dir"`
	// LogDir is the base directory for VM and process logs.
	// Env: COCOON_LOG_DIR. Default: /var/log/cocoon.
	LogDir string `json:"log_dir" mapstructure:"log_dir"`
	// CHBinary is the path or name of the cloud-hypervisor executable.
	// Default: "cloud-hypervisor".
	CHBinary string `json:"ch_binary" mapstructure:"ch_binary"`
	// FCBinary is the path or name of the firecracker executable.
	// Default: "firecracker".
	FCBinary string `json:"fc_binary" mapstructure:"fc_binary"`
	// UseFirecracker selects Firecracker as the hypervisor backend.
	// Set via --fc flag. Default: false (use Cloud Hypervisor).
	UseFirecracker bool `json:"use_firecracker,omitempty" mapstructure:"use_firecracker"`
	// StopTimeoutSeconds is how long to wait for a guest to respond to an
	// ACPI power-button before falling back to SIGTERM/SIGKILL.
	// Default: 30.
	StopTimeoutSeconds int `json:"stop_timeout_seconds" mapstructure:"stop_timeout_seconds"`
	// PoolSize is the goroutine pool size for concurrent operations.
	// Defaults to runtime.NumCPU() if zero.
	PoolSize int `json:"pool_size" mapstructure:"pool_size"`
	// CNIConfDir is the directory for CNI plugin configuration files.
	// Default: /etc/cni/net.d.
	CNIConfDir string `json:"cni_conf_dir" mapstructure:"cni_conf_dir"`
	// CNIBinDir is the directory for CNI plugin binaries.
	// Default: /opt/cni/bin.
	CNIBinDir string `json:"cni_bin_dir" mapstructure:"cni_bin_dir"`
	// DNS is a comma or semicolon separated list of DNS server addresses
	// injected into VM network configuration.
	// Env: COCOON_DNS. Default: "8.8.8.8,1.1.1.1".
	DNS string `json:"dns" mapstructure:"dns"`
	// SocketWaitTimeoutSeconds is how long to wait for the CH API socket
	// after process start. Default: 5. Increase for slow storage.
	SocketWaitTimeoutSeconds int `json:"socket_wait_timeout_seconds" mapstructure:"socket_wait_timeout_seconds"`
	// TerminateGracePeriodSeconds is the SIGTERM→SIGKILL window when
	// force-killing a CH process. Default: 5.
	TerminateGracePeriodSeconds int `json:"terminate_grace_period_seconds" mapstructure:"terminate_grace_period_seconds"`
	// Log configuration, uses eru core's ServerLogConfig.
	Log *coretypes.ServerLogConfig `json:"log" mapstructure:"log"`
}

Config holds global Cocoon configuration.

func (*Config) DNSServers

func (c *Config) DNSServers() ([]string, error)

DNSServers parses the DNS string into a slice of server addresses. Returns an error if any entry is not a valid IP address.

func (*Config) EffectivePoolSize added in v0.2.5

func (c *Config) EffectivePoolSize() int

EffectivePoolSize returns PoolSize if set, otherwise runtime.NumCPU().

func (*Config) Hypervisor added in v0.2.9

func (c *Config) Hypervisor() HypervisorType

Hypervisor returns the selected hypervisor backend type.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that all config fields are within acceptable ranges. Should be called once at startup after unmarshalling.

type HypervisorType added in v0.2.9

type HypervisorType string

HypervisorType identifies the selected hypervisor backend.

const (
	HypervisorCH          HypervisorType = "cloud-hypervisor"
	HypervisorFirecracker HypervisorType = "firecracker"
)

Jump to

Keyboard shortcuts

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