diff --git a/services/server/config/config.go b/services/server/config/config.go index 57dc71585..e3aacbae8 100644 --- a/services/server/config/config.go +++ b/services/server/config/config.go @@ -292,17 +292,15 @@ func resolveImports(parent string, imports []string) ([]string, error) { } // mergeConfig merges Config structs with the following rules: -// 'to' 'from' 'result' overwrite? -// "" "value" "value" yes -// "value" "" "value" no -// 1 0 1 no -// 0 1 1 yes -// []{"1"} []{"2"} []{"2"} yes -// []{"1"} []{} []{"1"} no +// 'to' 'from' 'result' +// "" "value" "value" +// "value" "" "value" +// 1 0 1 +// 0 1 1 +// []{"1"} []{"2"} []{"1","2"} +// []{"1"} []{} []{"1"} func mergeConfig(to, from *Config) error { - return mergo.Merge(to, from, func(config *mergo.Config) { - config.Overwrite = true - }) + return mergo.Merge(to, from, mergo.WithOverride, mergo.WithAppendSlice) } // V1DisabledFilter matches based on ID diff --git a/services/server/config/config_test.go b/services/server/config/config_test.go index 8e65a4630..2f0848894 100644 --- a/services/server/config/config_test.go +++ b/services/server/config/config_test.go @@ -35,12 +35,14 @@ func TestMergeConfigs(t *testing.T) { DisabledPlugins: []string{"old_plugin"}, State: "old_state", OOMScore: 1, + Timeouts: map[string]string{"a": "1"}, } b := &Config{ Root: "new_root", RequiredPlugins: []string{"new_plugin1", "new_plugin2"}, OOMScore: 2, + Timeouts: map[string]string{"b": "2"}, } err := mergeConfig(a, b) @@ -50,8 +52,9 @@ func TestMergeConfigs(t *testing.T) { assert.Equal(t, a.Root, "new_root") assert.Equal(t, a.State, "old_state") assert.Equal(t, a.OOMScore, 2) - assert.DeepEqual(t, a.RequiredPlugins, []string{"new_plugin1", "new_plugin2"}) + assert.DeepEqual(t, a.RequiredPlugins, []string{"old_plugin", "new_plugin1", "new_plugin2"}) assert.DeepEqual(t, a.DisabledPlugins, []string{"old_plugin"}) + assert.DeepEqual(t, a.Timeouts, map[string]string{"a": "1", "b": "2"}) } func TestResolveImports(t *testing.T) {