36 lines
1019 B
Go
36 lines
1019 B
Go
// Package config loads control-plane settings from the environment (see architecture plan §1).
|
|
package config
|
|
|
|
import (
|
|
"os"
|
|
"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
|
|
}
|
|
|
|
// 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"))
|
|
return e
|
|
}
|