-
Notifications
You must be signed in to change notification settings - Fork 508
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
switch to envconfig for configuration #284
Comments
@arschles Should we have a config struct with all of our expected environment variables? |
I think so @marwan-at-work. What do you think about using an init to first load the config, then the subsequent calls can return needed variables? |
👍 for a configuration file. keep dev defaults there. we can inject/replace the file with test/prod env easily on deploy |
What about having a json or toml representation of that config struct and so instead of populating env variables and keeping track of them, we just have one file where all this stuff lives. type Config struct {
GoBinPath string
OlympusGlobalURL string
DebugLevel string
...
} And then we can have several json representations for different environments: config.local.json {
"GoBinPath": "go",
"OlympusGlobalURL": "http://localhost:3001",
"DebugLevel": "debug"
} and then config.prod.json {
"GoBinPath": "go",
"OlympusGlobalURL": "https://www.olympus.com",
"DebugLevel": "warning"
} This way we don't need envconfig, or we can use it for overrides in the config if we really want to. Which is cool w/ me. We can also use https://github.com/go-playground/validator to validate that some Config fields are required as such type Config struct {
GoBinPath string `validate:"required"`
OlympusGlobalURL string `env:"OLYMPUS_GLOBAL_URL"`
DebugLevel string
...
} |
I'll work on this! |
the
./pkg/config/env
package has lots and lots ofenvy.Get
(and friends) calls, with defaults, type conversions, etc...let's remove all that duplicated code and use envconfig
The text was updated successfully, but these errors were encountered: