Skip to content

Commit

Permalink
merge: Allow duplicate keys in lhs
Browse files Browse the repository at this point in the history
This not only affects merge but also `Compare` since they use the same
algorithm/code.

Duplicates fields in a set/associative-list will now be treated as an
atomic entity within that list, and will be entirely owned by the person
who made them duplicates or who changed one of the duplicates.
  • Loading branch information
apelisse committed Oct 26, 2023
1 parent e0346c0 commit 29babbc
Show file tree
Hide file tree
Showing 3 changed files with 812 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/fixture/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (s *State) UpdateObject(tv *typed.TypedValue, version fieldpath.APIVersion,

// Update the current state with the passed in object
func (s *State) Update(obj typed.YAMLObject, version fieldpath.APIVersion, manager string) error {
tv, err := s.Parser.Type(string(version)).FromYAML(FixTabsOrDie(obj))
tv, err := s.Parser.Type(string(version)).FromYAML(FixTabsOrDie(obj), typed.AllowDuplicates)
if err != nil {
return err
}
Expand Down Expand Up @@ -174,7 +174,7 @@ func (s *State) CompareLive(obj typed.YAMLObject, version fieldpath.APIVersion)
if err := s.checkInit(version); err != nil {
return "", err
}
tv, err := s.Parser.Type(string(version)).FromYAML(obj)
tv, err := s.Parser.Type(string(version)).FromYAML(obj, typed.AllowDuplicates)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -461,7 +461,7 @@ func (u Update) run(state *State) error {
}

func (u Update) preprocess(parser Parser) (Operation, error) {
tv, err := parser.Type(string(u.APIVersion)).FromYAML(FixTabsOrDie(u.Object))
tv, err := parser.Type(string(u.APIVersion)).FromYAML(FixTabsOrDie(u.Object), typed.AllowDuplicates)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 29babbc

Please sign in to comment.