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
- func ApplyEnv(fs *pflag.FlagSet, lookup func(string) (string, bool)) error
- func BindDataDirFlag(fs *pflag.FlagSet, c *Config)
- func BindListenFlags(fs *pflag.FlagSet, c *Config)
- func BindSecretKeyFlag(fs *pflag.FlagSet, c *Config)
- func BindServeFlags(fs *pflag.FlagSet, c *Config)
- func BindTLSCertFlag(fs *pflag.FlagSet, c *Config)
- func EnvName(flag string) string
- func NormalizeBasePath(p string) (string, error)
- type Config
Constants ¶
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).
const EnvPrefix = "NERDUI_"
EnvPrefix is the prefix of environment variables mirroring flags.
Variables ¶
This section is empty.
Functions ¶
func ApplyEnv ¶
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 ¶
BindDataDirFlag registers only --data-dir (shared by serve and admin commands).
func BindListenFlags ¶
BindListenFlags registers --listen and --tls (shared by serve and healthcheck).
func BindSecretKeyFlag ¶ added in v0.2.0
BindSecretKeyFlag registers --secret-key-file (shared by serve and admin restore).
func BindServeFlags ¶
BindServeFlags registers the server flags on fs, storing values into c. c should be initialized with Default() so flag defaults match.
func BindTLSCertFlag ¶
BindTLSCertFlag registers --tls-cert (shared by serve and healthcheck).
func EnvName ¶
EnvName returns the environment variable for a flag, e.g. "data-dir" -> "NERDUI_DATA_DIR".
func NormalizeBasePath ¶ added in v0.2.0
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 (Config) EffectiveSecretKeyFile ¶ added in v0.2.0
EffectiveSecretKeyFile returns SecretKeyFile or its default inside DataDir.
func (Config) EffectiveStacksDir ¶
EffectiveStacksDir returns StacksDir or its default inside DataDir.
func (Config) EnsureDataDir ¶
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.