-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support reading configs from environment variables #448
Comments
Although I am not a big fan of configuration via environment variables, I don't necessary say it's a bad idea. IMHO the above is proposing a bit custom syntax with |
I seem to remember seeing something like this on the library viper. OTEL uses koanf instead. Seems they faced some issues in the past using viper. It would be a nice to have, but my intention was not to move larger blocks. What I had in mind was something simple like this snippet.func readCfgOrFatal(cfgPath string) string {
if strings.HasPrefix(cfgPath, "env:") {
env := strings.Replace(cfgPath, "env:", "", 1)
return os.Getenv(env)
}
f, err := os.ReadFile(cfgPath)
if err != nil {
stdlog.Fatalf("cannot read configuration file from path %q: %v", cfgPath, err)
}
return string(f)
} |
If I understood @periklis that would make sense to me as well - just have a predefined env var name which serves as an alternative to flag. Then:
|
Currently only file paths to the configs can be specified:
While there is nothing wrong with it, i think ability to provide these configurations via environment variables would simplify the usage.
Like this:
wdyt?
The text was updated successfully, but these errors were encountered: