config

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 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: ephemeral runtime state (PID files, sockets). 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: guest ACPI grace before SIGTERM/SIGKILL escalation. 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: comma/semicolon-separated DNS servers injected into VM net config. 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"`
	// Metering selects the lifecycle-event recorder backend.
	Metering MeteringConfig `json:"metering,omitzero" mapstructure:"metering"`
}

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 FileMeteringConfig added in v0.4.2

type FileMeteringConfig struct {
	Path string `json:"path,omitempty" mapstructure:"path"`
}

FileMeteringConfig parameterizes the file-backend recorder; empty Path resolves to <RootDir>/metering/ledger.jsonl.

type HypervisorType added in v0.2.9

type HypervisorType string

HypervisorType identifies the selected hypervisor backend.

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

type MeteringBackend added in v0.4.2

type MeteringBackend string

MeteringBackend identifies the lifecycle-event recorder backend.

const (
	MeteringFile   MeteringBackend = "file"
	MeteringNop    MeteringBackend = "nop"
	MeteringStderr MeteringBackend = "stderr"
)

type MeteringConfig added in v0.4.2

type MeteringConfig struct {
	Backend MeteringBackend    `json:"backend,omitempty" mapstructure:"backend"`
	File    FileMeteringConfig `json:"file,omitzero"     mapstructure:"file"`
}

MeteringConfig selects the recorder backend; empty Backend defaults to MeteringFile.

func (MeteringConfig) Validate added in v0.4.2

func (m MeteringConfig) Validate() error

Jump to

Keyboard shortcuts

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