From ccd80a210d612ba2c445ef4d8fbf9c1689f661ba Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Mon, 16 Oct 2023 12:18:28 +0200 Subject: [PATCH] fix TestLoadMultipleUlimits Signed-off-by: Nicolas De Loof --- loader/merge_test.go | 5 ----- override/merge.go | 11 ++++++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/loader/merge_test.go b/loader/merge_test.go index d98fdde4..c3b7cbdc 100644 --- a/loader/merge_test.go +++ b/loader/merge_test.go @@ -721,11 +721,6 @@ func TestLoadMultipleUlimits(t *testing.T) { Scale: 1, }, }, - Networks: types.Networks{}, - Volumes: types.Volumes{}, - Secrets: types.Secrets{}, - Configs: types.Configs{}, - Extensions: types.Extensions{}, }, config) }) } diff --git a/override/merge.go b/override/merge.go index 36e0dca0..28592f48 100644 --- a/override/merge.go +++ b/override/merge.go @@ -43,6 +43,7 @@ func init() { mergeSpecials["services.*.entrypoint"] = override mergeSpecials["services.*.healthcheck.test"] = override mergeSpecials["services.*.environment"] = mergeEnvironment + mergeSpecials["services.*.ulimits.*"] = mergeUlimit } // mergeYaml merges map[string]any yaml trees handling special rules @@ -60,7 +61,7 @@ func mergeYaml(e any, o any, p tree.Path) (any, error) { case map[string]any: other, ok := o.(map[string]any) if !ok { - return nil, fmt.Errorf("cannont override %s", p) + return nil, fmt.Errorf("cannot override %s", p) } return mergeMappings(value, other, p) case []any: @@ -124,6 +125,14 @@ func mergeEnvironment(c any, o any, p tree.Path) (any, error) { return append(right, left...), nil } +func mergeUlimit(c any, o any, p tree.Path) (any, error) { + over, ismapping := o.(map[string]any) + if base, ok := o.(map[string]any); ok && ismapping { + return mergeMappings(base, over, p) + } + return o, nil +} + func convertIntoSequence(value any) []any { switch v := value.(type) { case map[string]any: