From 00f16046e0fa6e73d2c9286a84f56a39cbccd10b Mon Sep 17 00:00:00 2001 From: = Date: Tue, 14 Sep 2021 23:18:58 +0200 Subject: [PATCH] Update config from env --- config/config.go | 1 + config/config_test.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/config/config.go b/config/config.go index 9b1fcbd..cc04f35 100644 --- a/config/config.go +++ b/config/config.go @@ -43,6 +43,7 @@ func FromReader(r io.Reader) (*Config, error) { if err := decoder.Decode(&c); err != nil { return nil, fmt.Errorf("error parsing config file: %w", err) } + c.UpdateFromEnv() return &c, c.Verify() } diff --git a/config/config_test.go b/config/config_test.go index 2ddd9d0..bbe5e7a 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -98,6 +98,12 @@ func TestConfig(t *testing.T) { if c.LogLevel != envValues["DOGTAMER_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) { os.Clearenv()