fix: change mergo settings

This commit is contained in:
Kevin Franklin Kim 2024-10-22 17:36:32 +02:00
parent 6774588349
commit 2383287728
No known key found for this signature in database
5 changed files with 18 additions and 4 deletions

View File

@ -58,11 +58,12 @@ func (u *Unit) UnmarshalYAML(value *yaml.Node) error {
if err := yaml.Unmarshal(defaults, &m); err != nil { if err := yaml.Unmarshal(defaults, &m); err != nil {
return errors.Wrap(err, "failed to unmarshal defaults") return errors.Wrap(err, "failed to unmarshal defaults")
} }
if err := mergo.Merge(&u.Values, m); err != nil { if err := mergo.Merge(&m, u.Values, mergo.WithAppendSlice, mergo.WithOverride, mergo.WithSliceDeepCopy); err != nil {
return err return err
} }
u.Extends = "" u.Extends = ""
u.Values = m
} }
return nil return nil
} }

View File

@ -14,6 +14,9 @@ squadron:
image: image:
repository: nginx repository: nginx
tag: latest tag: latest
null_obj: null
null_tags: null
tags: tags:
- ONE - ONE
- TWO - TWO
- THREE

View File

@ -14,6 +14,9 @@ squadron:
image: image:
repository: nginx repository: nginx
tag: latest tag: latest
null_obj: null
null_tags: null
tags: tags:
- ONE - ONE
- TWO - TWO
- THREE

View File

@ -5,4 +5,10 @@ env:
ONE: unknown ONE: unknown
THREE: baz THREE: baz
tags: tags:
- unknown - ONE
- TWO
null_tags:
- TWO
null_obj:
ONE: unknown
THREE: baz

View File

@ -12,5 +12,6 @@ squadron:
ONE: foo ONE: foo
TWO: bar TWO: bar
tags: tags:
- ONE - THREE
- TWO null_obj: ~
null_tags: ~