config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 11 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
	// 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 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".

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
	// 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
	// DisableExec turns off the web terminal into containers (#15, ADR-0022).
	DisableExec bool
}

Config is the configuration of the nerdui server.

func Default

func Default() Config

Default returns the configuration with all default values.

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