config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config loads runtime configuration from flags and environment variables and resolves sensible cross-platform defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Addr is the listen address. Defaults to loopback only; binding to a
	// public interface is an explicit, conscious choice by the operator.
	Addr string
	// DataDir holds the SQLite database and any persisted secrets.
	DataDir string
	// SessionTTL is how long a logged-in session token stays valid.
	SessionTTL time.Duration
	// Dev enables developer conveniences (e.g. permissive CORS for Vite).
	Dev bool
	// MetricsToken, when set, requires a bearer token to scrape /metrics.
	// Empty means the endpoint is open (fine for loopback-only use).
	MetricsToken string

	// TLSCert/TLSKey are paths to a PEM certificate and key. When both are set,
	// the server speaks HTTPS directly (otherwise plain HTTP behind a proxy).
	TLSCert string
	TLSKey  string

	// Version is the build version string, set by main (not from flags/env).
	Version string
	// ConfigFile is the config file that was loaded, or "" if none.
	ConfigFile string

	// Metrics history backend. RedisAddr empty → in-memory ring buffer.
	RedisAddr        string
	RedisPassword    string
	RedisDB          int
	MetricsRetention time.Duration
}

Config holds all runtime options.

func Load

func Load() (Config, error)

Load parses flags/env/config-file and returns the resolved configuration.

Precedence (highest first): command-line flag → environment variable → config file → built-in default. The config file is a simple "KEY=VALUE" file using the same DC_* keys as the environment. Its path comes from -config, then $DC_CONFIG, then the platform default (/etc/docker-commander/ commander.conf on Unix, %ProgramData%\docker-commander\commander.conf on Windows); a missing default file is ignored, a missing explicit one errors.

func (Config) DBPath

func (c Config) DBPath() string

DBPath is the path to the SQLite database file.

Jump to

Keyboard shortcuts

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