// Package config loads control-plane settings from the environment (see architecture plan ยง1). package config import ( "os" "path/filepath" "strings" ) // Env holds shared process configuration for cmd/* entrypoints. type Env struct { HTTPAddr string ServiceName string GitSHA string // DatabaseURL is the PostgreSQL DSN when SQL-backed repositories are wired (empty in dev). DatabaseURL string // BrokerURL is NATS/Redis when the reference profile uses a message broker (empty in microVPS). BrokerURL string // RuntimeLogsDir is the absolute host path to Docker runtime log files (evobgp-all only). RuntimeLogsDir string // RuntimeLogsPolicyTenant overrides which tenant global_settings drive auto-cleanup (optional). RuntimeLogsPolicyTenant string } // Load reads EVOBGP_* environment variables with safe defaults. func Load() Env { e := Env{ HTTPAddr: ":8080", } if v := strings.TrimSpace(os.Getenv("EVOBGP_HTTP_ADDR")); v != "" { e.HTTPAddr = v } if v := strings.TrimSpace(os.Getenv("EVOBGP_SERVICE")); v != "" { e.ServiceName = v } e.GitSHA = strings.TrimSpace(os.Getenv("EVOBGP_GIT_SHA")) e.DatabaseURL = strings.TrimSpace(os.Getenv("EVOBGP_DATABASE_URL")) e.BrokerURL = strings.TrimSpace(os.Getenv("EVOBGP_BROKER_URL")) e.RuntimeLogsPolicyTenant = strings.TrimSpace(os.Getenv("EVOBGP_RUNTIME_LOGS_POLICY_TENANT")) if v := strings.TrimSpace(os.Getenv("EVOBGP_RUNTIME_LOGS_DIR")); v != "" { if abs, err := filepath.Abs(v); err == nil { e.RuntimeLogsDir = abs } else { e.RuntimeLogsDir = v } } return e }