feature/epic2-core-services #6

Merged
master merged 60 commits from feature/epic2-core-services into main 2025-11-07 10:23:20 +01:00
Showing only changes of commit 54e1866997 - Show all commits

View File

@@ -3,6 +3,7 @@ package config
import (
"fmt"
"strings"
"time"
"git.dcentral.systems/toolz/goplt/pkg/config"
@@ -95,9 +96,13 @@ func LoadConfig(env string) (config.ConfigProvider, error) {
// Enable environment variable support
v.AutomaticEnv()
// Environment variables can be set in UPPER_SNAKE_CASE format
// and will automatically map to nested keys (e.g., SERVER_PORT -> server.port)
// Viper handles this automatically with AutomaticEnv()
// Set env key replacer to convert UPPER_SNAKE_CASE to nested keys
// e.g., DATABASE_DSN -> database.dsn, SERVER_PORT -> server.port
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
// Bind specific environment variables to config keys
v.BindEnv("database.dsn", "DATABASE_DSN")
v.BindEnv("registry.consul.address", "REGISTRY_CONSUL_ADDRESS")
v.BindEnv("registry.type", "REGISTRY_TYPE")
return NewViperConfig(v), nil
}