diff --git a/loader/merge.go b/loader/merge.go index ce7c1dcf2..241447c73 100644 --- a/loader/merge.go +++ b/loader/merge.go @@ -113,7 +113,10 @@ func mergeServices(base, override []types.ServiceConfig) ([]types.ServiceConfig, } func _merge(baseService *types.ServiceConfig, overrideService *types.ServiceConfig) (*types.ServiceConfig, error) { - if err := mergo.Merge(baseService, overrideService, mergo.WithAppendSlice, mergo.WithOverride, mergo.WithTransformers(serviceSpecials)); err != nil { + if err := mergo.Merge(baseService, overrideService, + mergo.WithAppendSlice, + mergo.WithOverride, + mergo.WithTransformers(serviceSpecials)); err != nil { return nil, err } if overrideService.Command != nil { diff --git a/loader/merge_test.go b/loader/merge_test.go index 4f173b11b..bbe32cd2b 100644 --- a/loader/merge_test.go +++ b/loader/merge_test.go @@ -1110,6 +1110,45 @@ func TestMergeUlimitsConfig(t *testing.T) { ) } +func TestInitOverride(t *testing.T) { + var ( + bt = true + bf = false + ) + cases := []struct { + base *bool + override *bool + expect bool + }{ + { + base: &bt, + override: &bf, + expect: false, + }, + { + base: nil, + override: &bt, + expect: true, + }, + { + base: &bt, + override: nil, + expect: true, + }, + } + for _, test := range cases { + base := types.ServiceConfig{ + Init: test.base, + } + override := types.ServiceConfig{ + Init: test.override, + } + config, err := _merge(&base, &override) + assert.NilError(t, err) + assert.Check(t, *config.Init == test.expect) + } +} + func TestMergeServiceNetworkConfig(t *testing.T) { specials := &specials{ m: map[reflect.Type]func(dst, src reflect.Value) error{