config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config defines nerdui's runtime configuration: defaults, validation and filesystem preparation. Values come from command-line flags or NERDUI_* environment variables (see flags.go); precedence is flag > environment > default.

Index

Constants

View Source
const (
	DefaultListen            = ":9443"
	DefaultContainerdAddress = "/run/containerd/containerd.sock"
	DefaultNamespace         = "default"
	DefaultDataDir           = "/var/lib/nerdui"
	DefaultNerdctlPath       = "nerdctl"
	DefaultLogLevel          = "info"

	// DefaultEventsRetention keeps a week of event history (ADR-0021).
	DefaultEventsRetention = 7 * 24 * time.Hour
	// DefaultAuditRetention keeps 90 days of the audit log (ADR-0036).
	DefaultAuditRetention = 90 * 24 * time.Hour
	// DataDirMode is the permission of the data directory (ADR-0004).
	DataDirMode fs.FileMode = 0o700
)

Defaults. See docs/architecture.md (Configuration).

View Source
const EnvPrefix = "NERDUI_"

EnvPrefix is the prefix of environment variables mirroring flags.

Variables

This section is empty.

Functions

func ApplyEnv

func ApplyEnv(fs *pflag.FlagSet, lookup func(string) (string, bool)) error

ApplyEnv sets every flag that was not given on the command line from its NERDUI_* environment variable, if present. lookup is usually os.LookupEnv.

func BindDataDirFlag

func BindDataDirFlag(fs *pflag.FlagSet, c *Config)

BindDataDirFlag registers only --data-dir (shared by serve and admin commands).

func BindListenFlags

func BindListenFlags(fs *pflag.FlagSet, c *Config)

BindListenFlags registers --listen and --tls (shared by serve and healthcheck).

func BindSecretKeyFlag added in v0.2.0

func BindSecretKeyFlag(fs *pflag.FlagSet, c *Config)

BindSecretKeyFlag registers --secret-key-file (shared by serve and admin restore).

func BindServeFlags

func BindServeFlags(fs *pflag.FlagSet, c *Config)

BindServeFlags registers the server flags on fs, storing values into c. c should be initialized with Default() so flag defaults match.

func BindTLSCertFlag

func BindTLSCertFlag(fs *pflag.FlagSet, c *Config)

BindTLSCertFlag registers --tls-cert (shared by serve and healthcheck).

func EnvName

func EnvName(flag string) string

EnvName returns the environment variable for a flag, e.g. "data-dir" -> "NERDUI_DATA_DIR".

func NormalizeBasePath added in v0.2.0

func NormalizeBasePath(p string) (string, error)

NormalizeBasePath returns the path prefix without a trailing slash ("" for none, "/" too), e.g. "nerdui/" → "/nerdui".

Types

type Config

type Config struct {
	// Listen is the TCP address of the HTTP(S) server, e.g. ":9443" or "127.0.0.1:9443".
	Listen string
	// ContainerdAddress is the containerd socket path.
	ContainerdAddress string
	// Namespace is the default containerd namespace.
	Namespace string
	// DataDir holds nerdui's own state: database, TLS material, stacks (ADR-0004).
	DataDir string
	// StacksDir holds compose projects managed by nerdui; empty means <DataDir>/stacks (ADR-0008).
	StacksDir string
	// StacksScanDirs are extra directories scanned for existing compose projects (#25).
	StacksScanDirs []string
	// NerdctlPath is the host nerdctl binary used for hooks, logging and compose (ADR-0003).
	NerdctlPath string
	// SkipNerdctlVersionCheck disables the major.minor compatibility check (ADR-0011).
	SkipNerdctlVersionCheck bool
	// TLS enables HTTPS (default). Disable only behind a TLS-terminating reverse proxy.
	TLS bool
	// TLSCert and TLSKey are a user-provided PEM certificate and key; when both are empty a
	// self-signed certificate is generated in <DataDir>/tls (ADR-0005).
	TLSCert string
	TLSKey  string
	// TLSACMEDomains get certificates from an ACME CA such as Let's Encrypt (#113, ADR-0038).
	TLSACMEDomains []string
	// TLSACMEEmail is the ACME account contact (expiry notices); optional.
	TLSACMEEmail string
	// TLSACMECA is "production", "staging" (Let's Encrypt) or an ACME directory URL.
	TLSACMECA string
	// TLSACMEHTTP, when set, is an address (usually ":80") for HTTP-01 challenges and HTTP to
	// HTTPS redirects; without it only TLS-ALPN-01 on port 443 is used.
	TLSACMEHTTP string
	// LogLevel is one of debug, info, warn, error.
	LogLevel string
	// EventsRetention is how long the event history is kept (#65); 0 disables it.
	EventsRetention time.Duration
	// AuditRetention is how long the audit log is kept (#79); 0 keeps it forever.
	AuditRetention time.Duration
	// DisableExec turns off the web terminal into containers (#15, ADR-0022).
	DisableExec bool
	// TrustedProxies are the addresses (IPs or CIDRs) of reverse proxies whose X-Forwarded-*
	// headers are honored (#112, ADR-0035).
	TrustedProxies []string
	// BasePath serves nerdui under a path prefix such as /nerdui behind a reverse proxy (#222).
	BasePath string
	// SecretKeyFile holds the key that encrypts secrets in the database (#35, ADR-0049);
	// default <DataDir>/secret.key, created on first start.
	SecretKeyFile string
}

Config is the configuration of the nerdui server.

func Default

func Default() Config

Default returns the configuration with all default values.

func (Config) EffectiveSecretKeyFile added in v0.2.0

func (c Config) EffectiveSecretKeyFile() string

EffectiveSecretKeyFile returns SecretKeyFile or its default inside DataDir.

func (Config) EffectiveStacksDir

func (c Config) EffectiveStacksDir() string

EffectiveStacksDir returns StacksDir or its default inside DataDir.

func (Config) EnsureDataDir

func (c Config) EnsureDataDir() (insecure bool, err error)

EnsureDataDir creates the data directory with DataDirMode if it does not exist. It reports insecure=true when an existing directory is accessible by group or others; the permissions of an existing directory are never changed silently.

func (Config) SlogLevel

func (c Config) SlogLevel() slog.Level

SlogLevel returns the parsed log level. Call Validate first.

func (Config) TLSDir

func (c Config) TLSDir() string

TLSDir is where the self-signed certificate is kept.

func (Config) Validate

func (c Config) Validate() error

Validate checks the configuration and returns all problems at once.

Jump to

Keyboard shortcuts

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