@@ -1043,15 +1043,15 @@ func (ce *configPathError) Error() string {
10431043 return fmt .Sprintf ("Couldn't apply config override `%s`: %s" , ce .name , ce .desc )
10441044}
10451045
1046- func mungeFromEnvironment (config * Config , envPair string ) (applied bool , err * configPathError ) {
1046+ func mungeFromEnvironment (config * Config , envPair string ) (applied bool , name string , err * configPathError ) {
10471047 equalIdx := strings .IndexByte (envPair , '=' )
10481048 name , value := envPair [:equalIdx ], envPair [equalIdx + 1 :]
10491049 if strings .HasPrefix (name , "ERGO__" ) {
10501050 name = strings .TrimPrefix (name , "ERGO__" )
10511051 } else if strings .HasPrefix (name , "ORAGONO__" ) {
10521052 name = strings .TrimPrefix (name , "ORAGONO__" )
10531053 } else {
1054- return false , nil
1054+ return false , "" , nil
10551055 }
10561056 pathComponents := strings .Split (name , "__" )
10571057 for i , pathComponent := range pathComponents {
@@ -1062,10 +1062,10 @@ func mungeFromEnvironment(config *Config, envPair string) (applied bool, err *co
10621062 t := v .Type ()
10631063 for _ , component := range pathComponents {
10641064 if component == "" {
1065- return false , & configPathError {name , "invalid" , nil }
1065+ return false , "" , & configPathError {name , "invalid" , nil }
10661066 }
10671067 if v .Kind () != reflect .Struct {
1068- return false , & configPathError {name , "index into non-struct" , nil }
1068+ return false , "" , & configPathError {name , "index into non-struct" , nil }
10691069 }
10701070 var nextField reflect.StructField
10711071 success := false
@@ -1091,7 +1091,7 @@ func mungeFromEnvironment(config *Config, envPair string) (applied bool, err *co
10911091 }
10921092 }
10931093 if ! success {
1094- return false , & configPathError {name , fmt .Sprintf ("couldn't resolve path component: `%s`" , component ), nil }
1094+ return false , "" , & configPathError {name , fmt .Sprintf ("couldn't resolve path component: `%s`" , component ), nil }
10951095 }
10961096 v = v .FieldByName (nextField .Name )
10971097 // dereference pointer field if necessary, initialize new value if necessary
@@ -1105,9 +1105,9 @@ func mungeFromEnvironment(config *Config, envPair string) (applied bool, err *co
11051105 }
11061106 yamlErr := yaml .Unmarshal ([]byte (value ), v .Addr ().Interface ())
11071107 if yamlErr != nil {
1108- return false , & configPathError {name , "couldn't deserialize YAML" , yamlErr }
1108+ return false , "" , & configPathError {name , "couldn't deserialize YAML" , yamlErr }
11091109 }
1110- return true , nil
1110+ return true , name , nil
11111111}
11121112
11131113// LoadConfig loads the given YAML configuration file.
@@ -1119,15 +1119,15 @@ func LoadConfig(filename string) (config *Config, err error) {
11191119
11201120 if config .AllowEnvironmentOverrides {
11211121 for _ , envPair := range os .Environ () {
1122- applied , envErr := mungeFromEnvironment (config , envPair )
1122+ applied , name , envErr := mungeFromEnvironment (config , envPair )
11231123 if envErr != nil {
11241124 if envErr .fatalErr != nil {
11251125 return nil , envErr
11261126 } else {
11271127 log .Println (envErr .Error ())
11281128 }
11291129 } else if applied {
1130- log .Printf ("applied environment override: %s\n " , envPair )
1130+ log .Printf ("applied environment override: %s\n " , name )
11311131 }
11321132 }
11331133 }
0 commit comments