Documentation
¶
Overview ¶
Package cmd provides command-line argument parsing and configuration management functionality. Supports loading configuration from command-line arguments, environment variables and configuration files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSnapshotMaxAge ¶ added in v1.2.0
DefaultSnapshotMaxAge derives the default freshness threshold from the configured refresh interval while preserving a minimum scheduling margin.
func ParseHMACAllowV1 ¶ added in v1.0.0
ParseHMACAllowV1 parses the legacy HMAC v1 compatibility switch. The empty value is deliberately secure by default; v1 must be enabled explicitly.
func ParseHMACKeys ¶ added in v1.0.0
ParseHMACKeys parses and validates the complete key set. Key identifiers are trimmed for stable lookup; secrets are preserved byte-for-byte but may not be empty or whitespace-only. Invalid entries fail the whole set closed.
func ParseSnapshotMaxAge ¶ added in v1.2.0
ParseSnapshotMaxAge parses the maximum age accepted by health checks. An empty value derives a safe default from the refresh interval, with enough slack for transient scheduling delays. Operators may override it with a Go duration such as "2m"; non-positive values are rejected instead of disabling stale detection.
func ValidateConfig ¶
ValidateConfig validates configuration validity
Types ¶
type Config ¶
type Config struct {
ConfigFile string // resolved application configuration file path
Port string // 16 bytes
Redis string // 16 bytes
RedisPassword string // 16 bytes
RedisEnabled bool // 1 byte (padding to 8 bytes)
RemoteConfig string // 16 bytes
RemoteKey string // 16 bytes
Mode string // 16 bytes (merge mode; legacy MODE is a deprecated alias)
Environment string // env ENVIRONMENT: development|test|production (security policy)
LegacyModeUsedForEnv bool // true when legacy MODE was used to derive the environment (deprecation)
APIKey string // 16 bytes
DataFile string // 16 bytes - local user data file path
DataDir string // 16 bytes - local user data directory (merge *.json)
ResponseFields []string // API response field whitelist (empty = all)
RemoteDecryptEnabled bool // decrypt remote API response with RSA
RemoteRSAPrivateKeyFile string // path to PEM file for RSA decryption (preferred)
RemoteRSAPrivateKey string // inline PEM for RSA decryption (used when file not set)
RemoteEncryptionRequired bool // env REMOTE_ENCRYPTION_REQUIRED: fail closed on plaintext
RemoteEncryptionFormat string // env REMOTE_ENCRYPTION_FORMAT: auto|v2|legacy
UserIDStrategy string // env USER_ID_STRATEGY: legacy|sha256-128 (default legacy)
RequireExplicitUserID bool // env REQUIRE_EXPLICIT_USER_ID: reject records without user_id
TaskInterval int // 8 bytes
HTTPTimeout int // 8 bytes
HTTPMaxIdleConns int // 8 bytes
HTTPInsecureTLS bool // 1 byte (padding to 8 bytes)
HMACKeys string // JSON map key_id -> secret (env WARDEN_HMAC_KEYS)
HMACToleranceSec int // env WARDEN_HMAC_TIMESTAMP_TOLERANCE, default 60
TLSCertFile string // env WARDEN_TLS_CERT
TLSKeyFile string // env WARDEN_TLS_KEY
TLSCAFile string // env WARDEN_TLS_CA (client CA for mTLS)
TLSRequireClientCert bool // env WARDEN_TLS_REQUIRE_CLIENT_CERT
}
Config stores application configuration
func GetArgs
deprecated
func GetArgs() *Config
GetArgs parses command-line arguments and environment variables, returning a configuration struct. It panics when explicitly requested configuration cannot be parsed. New callers should use GetArgsWithError so the startup path can report the error cleanly.
Deprecated: use GetArgsWithError.
func GetArgsWithError ¶ added in v1.0.0
GetArgsWithError parses command-line arguments and environment variables. Priority: command-line arguments > environment variables > configuration file > default values The -config-file flag takes precedence over CONFIG_FILE. An explicitly requested configuration file is mandatory: parse, validation and filesystem errors are returned instead of silently falling back to development defaults.
func LoadConfig ¶
LoadConfig loads configuration (new interface, supports configuration file) Priority: command-line arguments > environment variables > configuration file > default values