DoH через DoWithRetry; CDN preview через UpstreamHTTPDo; частичный fail CDN (EVOBGP_CDN_PARTIAL_OK); безопасный доступ к Job.Meta; drain jobs при SIGTERM; ValidateProductionEnforce при EVOBGP_PRODUCTION=1. Co-authored-by: Cursor <[email protected]>
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// ProductionMode reports whether EVOBGP_PRODUCTION / EVOBGP_ENV=production is set.
|
|
func ProductionMode() bool {
|
|
if v := strings.TrimSpace(os.Getenv("EVOBGP_PRODUCTION")); v == "1" || strings.EqualFold(v, "true") {
|
|
return true
|
|
}
|
|
env := strings.ToLower(strings.TrimSpace(os.Getenv("EVOBGP_ENV")))
|
|
return env == "production" || env == "prod"
|
|
}
|
|
|
|
// ValidateProductionEnforce enforces docs/production-checklist.md hard requirements
|
|
// when ProductionMode() is true. Returns an error that should abort process start.
|
|
func ValidateProductionEnforce() error {
|
|
if !ProductionMode() {
|
|
return nil
|
|
}
|
|
seedDemo := os.Getenv("EVOBGP_SEED_DEMO")
|
|
if seedDemo != "0" {
|
|
return fmt.Errorf("config: production requires EVOBGP_SEED_DEMO=0 (got %q)", seedDemo)
|
|
}
|
|
if strings.TrimSpace(os.Getenv("EVOBGP_DEV_INSECURE")) == "1" {
|
|
return fmt.Errorf("config: production forbids EVOBGP_DEV_INSECURE=1")
|
|
}
|
|
if strings.TrimSpace(os.Getenv("EVOBGP_BUNDLE_SEED_HEX")) == "" {
|
|
return fmt.Errorf("config: production requires EVOBGP_BUNDLE_SEED_HEX")
|
|
}
|
|
if strings.TrimSpace(os.Getenv("EVOBGP_CDN_ALLOW_PRIVATE")) == "1" {
|
|
return fmt.Errorf("config: production forbids EVOBGP_CDN_ALLOW_PRIVATE=1")
|
|
}
|
|
return nil
|
|
}
|