Fix: viper.UnmarshalKey ignores defaults
This seems to be a bug in viper, as soon as we're working with subkeys, things fall apart
This commit is contained in:
		@@ -34,7 +34,13 @@ func SetConfigDefaults() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func LoadConfig() {
 | 
			
		||||
	viper.UnmarshalKey("Service", &C)
 | 
			
		||||
	// Does not work with partially overrides, only GetXXX does resolve the subkeys correctly
 | 
			
		||||
	// https://github.com/spf13/viper/issues/798
 | 
			
		||||
	// https://github.com/spf13/viper/issues/309
 | 
			
		||||
	// viper.UnmarshalKey("Service", &C)
 | 
			
		||||
	C.DNS.Server = viper.GetString("Service.DNS.Server")
 | 
			
		||||
	C.DNS.DefaultTTL = viper.GetUint32("Service.DNS.DefaultTTL")
 | 
			
		||||
	C.Users.ConfigDir = viper.GetString("Service.Users.ConfigDir")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (obj *config) PrettyPrint() string {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user