Skip to content

Commit

Permalink
Merge pull request #77 from foomo/extends-mergo
Browse files Browse the repository at this point in the history
fix: change mergo settings
  • Loading branch information
franklinkim authored Oct 22, 2024
2 parents 6774588 + 2383287 commit dbc98c5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/config/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ func (u *Unit) UnmarshalYAML(value *yaml.Node) error {
if err := yaml.Unmarshal(defaults, &m); err != nil {
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
}

u.Extends = ""
u.Values = m
}
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions testdata/extends/snapshop-config-norender.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ squadron:
image:
repository: nginx
tag: latest
null_obj: null
null_tags: null
tags:
- ONE
- TWO
- THREE
3 changes: 3 additions & 0 deletions testdata/extends/snapshop-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ squadron:
image:
repository: nginx
tag: latest
null_obj: null
null_tags: null
tags:
- ONE
- TWO
- THREE
8 changes: 7 additions & 1 deletion testdata/extends/squadron.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ env:
ONE: unknown
THREE: baz
tags:
- unknown
- ONE
- TWO
null_tags:
- TWO
null_obj:
ONE: unknown
THREE: baz
5 changes: 3 additions & 2 deletions testdata/extends/squadron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ squadron:
ONE: foo
TWO: bar
tags:
- ONE
- TWO
- THREE
null_obj: ~
null_tags: ~

0 comments on commit dbc98c5

Please sign in to comment.