diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-22 09:53:37 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-22 21:38:28 +0200 |
commit | 4a9d408fe0bbf4c563546e35d2be7ade4e920c4c (patch) | |
tree | 942f920d5b829ab04b2e5786a712a713beb84f53 /config/defaultConfigProvider.go | |
parent | 93120598880ae7c598f186f5259fc4d5a286632f (diff) |
config: Fix merge of config with map[string]string values.
Fixes #8679
Diffstat (limited to 'config/defaultConfigProvider.go')
-rw-r--r-- | config/defaultConfigProvider.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/config/defaultConfigProvider.go b/config/defaultConfigProvider.go index d9c9db7f1..fd32c08a6 100644 --- a/config/defaultConfigProvider.go +++ b/config/defaultConfigProvider.go @@ -163,10 +163,9 @@ func (c *defaultConfigProvider) Set(k string, v interface{}) { } switch vv := v.(type) { - case map[string]interface{}: - var p maps.Params = vv + case map[string]interface{}, map[interface{}]interface{}, map[string]string: + p := maps.MustToParamsAndPrepare(vv) v = p - maps.PrepareParams(p) } key, m := c.getNestedKeyAndMap(k, true) @@ -183,6 +182,16 @@ func (c *defaultConfigProvider) Set(k string, v interface{}) { m[key] = v } +// SetDefaults will set values from params if not already set. +func (c *defaultConfigProvider) SetDefaults(params maps.Params) { + maps.PrepareParams(params) + for k, v := range params { + if _, found := c.root[k]; !found { + c.root[k] = v + } + } +} + func (c *defaultConfigProvider) Merge(k string, v interface{}) { c.mu.Lock() defer c.mu.Unlock() @@ -226,10 +235,9 @@ func (c *defaultConfigProvider) Merge(k string, v interface{}) { } switch vv := v.(type) { - case map[string]interface{}: - var p maps.Params = vv + case map[string]interface{}, map[interface{}]interface{}, map[string]string: + p := maps.MustToParamsAndPrepare(vv) v = p - maps.PrepareParams(p) } key, m := c.getNestedKeyAndMap(k, true) |