Update config from env
This commit is contained in:
parent
3c79a1de8c
commit
00f16046e0
@ -43,6 +43,7 @@ func FromReader(r io.Reader) (*Config, error) {
|
|||||||
if err := decoder.Decode(&c); err != nil {
|
if err := decoder.Decode(&c); err != nil {
|
||||||
return nil, fmt.Errorf("error parsing config file: %w", err)
|
return nil, fmt.Errorf("error parsing config file: %w", err)
|
||||||
}
|
}
|
||||||
|
c.UpdateFromEnv()
|
||||||
|
|
||||||
return &c, c.Verify()
|
return &c, c.Verify()
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,12 @@ func TestConfig(t *testing.T) {
|
|||||||
if c.LogLevel != envValues["DOGTAMER_LOGLEVEL"] {
|
if c.LogLevel != envValues["DOGTAMER_LOGLEVEL"] {
|
||||||
t.Errorf("LogLevel has wrong value: %s", c.LogLevel)
|
t.Errorf("LogLevel has wrong value: %s", c.LogLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.Cleanup(func() {
|
||||||
|
for value := range envValues {
|
||||||
|
os.Unsetenv(value)
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
t.Run("TestFromEnvInvalid", func(t *testing.T) {
|
t.Run("TestFromEnvInvalid", func(t *testing.T) {
|
||||||
os.Clearenv()
|
os.Clearenv()
|
||||||
|
Loading…
Reference in New Issue
Block a user