@@ -146,12 +146,12 @@ func confFromEnv() (ServerConfig, error) {
146
146
"fnv1" : fnv1 .HashBytes32 ,
147
147
"crc32" : nil ,
148
148
}
149
- if fn , ok := hashFuncs [hash ]; ok {
150
- conf .Picker = gubernator .NewConsistantHash (fn )
151
- return conf , nil
149
+ fn , ok := hashFuncs [hash ]
150
+ if ! ok {
151
+ return conf , errors .Errorf ("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]" ,
152
+ hash , validHashKeys (hashFuncs ))
152
153
}
153
- return conf , errors .Errorf ("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]" ,
154
- hash , validHashKeys (hashFuncs ))
154
+ conf .Picker = gubernator .NewConsistantHash (fn )
155
155
156
156
case "replicated-hash" :
157
157
setter .SetDefault (& replicas , getEnvInteger ("GUBER_REPLICATED_HASH_REPLICAS" ), 1 )
@@ -161,12 +161,14 @@ func confFromEnv() (ServerConfig, error) {
161
161
"fnv1a" : fnv1a .HashBytes64 ,
162
162
"fnv1" : fnv1 .HashBytes64 ,
163
163
}
164
- if fn , ok := hashFuncs [hash ]; ok {
165
- conf .Picker = gubernator .NewReplicatedConsistantHash (fn , replicas )
166
- return conf , nil
164
+ fn , ok := hashFuncs [hash ]
165
+ if ! ok {
166
+ return conf , errors .Errorf ("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]" ,
167
+ hash , validHash64Keys (hashFuncs ))
167
168
}
168
- return conf , errors .Errorf ("'GUBER_PEER_PICKER_HASH=%s' is invalid; choices are [%s]" ,
169
- hash , validHash64Keys (hashFuncs ))
169
+ conf .Picker = gubernator .NewReplicatedConsistantHash (fn , replicas )
170
+ default :
171
+ return conf , errors .Errorf ("'GUBER_PEER_PICKER=%s' is invalid; choices are ['replicated-hash', 'consistent-hash']" , pp )
170
172
}
171
173
}
172
174
@@ -328,7 +330,7 @@ func fromEnvFile(configFile string) error {
328
330
return errors .Errorf ("malformed key=value on line '%d'" , i )
329
331
}
330
332
331
- if err := os .Setenv (parts [0 ], parts [1 ]); err != nil {
333
+ if err := os .Setenv (strings . TrimSpace ( parts [0 ]), strings . TrimSpace ( parts [1 ]) ); err != nil {
332
334
return errors .Wrapf (err , "while settings environ for '%s=%s'" , parts [0 ], parts [1 ])
333
335
}
334
336
}
0 commit comments