config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config parses and validates the agent's entire startup surface.

Every knob is an environment variable read exactly once, at start, and immutable thereafter. This is the agent's core security property: its powers are fixed by the operator's startup configuration, never by a client. There is deliberately no API, file, or signal that can change any value here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StateDir      string
	ListenAddr    string
	PublicAddrs   []string
	PolicyMode    policy.Mode
	DockerHost    string
	LogLevel      slog.Level
	LogMaxAge     time.Duration
	LogMaxTotalMB int
	AuditMaxAge   time.Duration
	AuditMaxRows  int

	RateStatusPerMin  int
	RatePairPerMin    int
	RateGuardedPerSec int

	// SelfContainer is an operator-supplied name-or-ID override for the
	// agent's own container, used when the agent cannot detect it
	// automatically. A container name (container_name: / --name) is the form
	// worth using: docker compose up -d recreates the container whenever the
	// compose file changes and mints a new ID, so an ID copied out of docker
	// ps is stale on the very next boot, while a name survives recreation.
	// Empty is the normal case; it has no default.
	SelfContainer string
}

Config is the fully parsed, validated startup configuration.

func Load

func Load(getenv func(string) string) (Config, error)

Load reads the configuration from getenv, applies defaults, and validates.

getenv is a parameter rather than a direct call to os.Getenv so tests can supply a fake map without mutating process state — t.Setenv forbids t.Parallel, and this package's table test is the largest in the repository.

On failure it returns a *ValidationError listing every problem, never just the first, and a zero Config that callers must not use.

func (Config) AgentLogPath

func (c Config) AgentLogPath() string

AgentLogPath is the current operational log file.

func (Config) CertsDir

func (c Config) CertsDir() string

CertsDir holds the server keypair (and, from Phase 2, the CA).

func (Config) DBPath

func (c Config) DBPath() string

DBPath is the SQLite state store.

func (Config) LogsDir

func (c Config) LogsDir() string

LogsDir holds the rotated operational logs.

type ValidationError

type ValidationError struct{ Problems []string }

ValidationError reports every problem found in one pass.

It aggregates rather than failing on the first fault: an operator correcting a `docker run` line one variable at a time, one restart at a time, is a bad first experience and the exact thing this package exists to avoid.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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