-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Hello, it would be nice if the error for when there is a missing variable expansion states that it is missing instead of "empty default". Example below.
go version - 1.21.2
uber-go/config version - 1.4.0
sidecar:
global-tags:
- "pod=$MY_POD_NAME"
- "namespace=$MY_NAMESPACE"main: go
func main() {
cfgProvider, err := config.NewYAML(config.Source(strings.NewReader("sidecar: { log-level: INFO, global-tags: [pod=$POD, namespace=$NAMESPACE]}")), config.Expand(os.LookupEnv))
if err != nil {
zap.L().Fatal("could not read yaml config", zap.Error(err))
}
var cfg AppConfig
if err := cfgProvider.Get("sidecar").Populate(&cfg); err != nil {
zap.L().Fatal("could not read app config", zap.Error(err))
}
}
output:
go run main.go # no exported env vars
{"level":"fatal","message":"could not read yaml config","error":"couldn't expand environment: default is empty for \"POD\" (use \"\" for empty string)"}
It would be clearer if the error was - "missing expansion variable {VAR_NAME}" instead of "default is empty".
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels