diff --git a/internal/adapter/templates/templates/components/service/cmd/server/main.go.tmpl b/internal/adapter/templates/templates/components/service/cmd/server/main.go.tmpl index 8195c85..1ef61c9 100644 --- a/internal/adapter/templates/templates/components/service/cmd/server/main.go.tmpl +++ b/internal/adapter/templates/templates/components/service/cmd/server/main.go.tmpl @@ -24,6 +24,7 @@ import ( emailpkg "{{GO_MODULE}}/pkg/email" "{{GO_MODULE}}/pkg/notify" "{{GO_MODULE}}/pkg/queue" + pkgconfig "{{GO_MODULE}}/pkg/config" "{{GO_MODULE}}/pkg/realtime" "{{GO_MODULE}}/pkg/storage" "{{GO_MODULE}}/pkg/textgen" @@ -58,6 +59,13 @@ func main() { os.Exit(0) } + // Initialize viper with AutomaticEnv so Viper reads env vars injected by + // the platform (K8s secrets, envFrom). Must happen before any config reads. + pkgconfig.MustInit(pkgconfig.Options{ + AppName: "{{COMPONENT_NAME}}", + DefaultPort: {{PORT}}, + }) + // Load config cfg := config.Load()