-
-
Notifications
You must be signed in to change notification settings - Fork 709
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
Define defaults using viper.SetDefault #208
Comments
It's not likely to be fixed in the near future :\ Mostly because it's not trivial to fix and all the potential solutions have their own downsides. As far as I can tell, you already set defaults. Not in Viper, but in the global struct directly. So instead of doing that, you could just set the defaults in Viper. :) |
I would like to avoid to manually set the defaults in viper, it is error prone since I have to write both the key and the value manually, I'll eventually try one the wrapper suggested on the linked viper bug |
Either way, tests should probably make sure of the correct behavior. |
I noticed a slight issue around configuration. Namely: if the config file containing defaults is missing, environment variables are not recognized.
The root cause of this issue is this: spf13/viper#761
Basically,
AutomaticEnv
doesn't work withUnmarshal
when the keys that env vars are mapped to does not already exist in Viper via some other way.AutomaticEnv
tries to look for those keys in environment variables when unmarshaling values on a struct.I recommend using
SetDefault
to set default values (even empty ones), so that the config file does not have to contain all default/empty values for sftpgo to work.The text was updated successfully, but these errors were encountered: