Skip to content

Commit 29babbc

Browse files
committed
merge: Allow duplicate keys in lhs
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.
1 parent e0346c0 commit 29babbc

File tree

3 files changed

+812
-4
lines changed

3 files changed

+812
-4
lines changed

Diff for: internal/fixture/state.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (s *State) UpdateObject(tv *typed.TypedValue, version fieldpath.APIVersion,
131131

132132
// Update the current state with the passed in object
133133
func (s *State) Update(obj typed.YAMLObject, version fieldpath.APIVersion, manager string) error {
134-
tv, err := s.Parser.Type(string(version)).FromYAML(FixTabsOrDie(obj))
134+
tv, err := s.Parser.Type(string(version)).FromYAML(FixTabsOrDie(obj), typed.AllowDuplicates)
135135
if err != nil {
136136
return err
137137
}
@@ -174,7 +174,7 @@ func (s *State) CompareLive(obj typed.YAMLObject, version fieldpath.APIVersion)
174174
if err := s.checkInit(version); err != nil {
175175
return "", err
176176
}
177-
tv, err := s.Parser.Type(string(version)).FromYAML(obj)
177+
tv, err := s.Parser.Type(string(version)).FromYAML(obj, typed.AllowDuplicates)
178178
if err != nil {
179179
return "", err
180180
}
@@ -461,7 +461,7 @@ func (u Update) run(state *State) error {
461461
}
462462

463463
func (u Update) preprocess(parser Parser) (Operation, error) {
464-
tv, err := parser.Type(string(u.APIVersion)).FromYAML(FixTabsOrDie(u.Object))
464+
tv, err := parser.Type(string(u.APIVersion)).FromYAML(FixTabsOrDie(u.Object), typed.AllowDuplicates)
465465
if err != nil {
466466
return nil, err
467467
}

0 commit comments

Comments
 (0)