Skip to content

Commit

Permalink
Merge pull request #242 from kmala/master
Browse files Browse the repository at this point in the history
deep copy slice object during append
  • Loading branch information
k8s-ci-robot authored Jul 10, 2023
2 parents a345f52 + 69bc7e7 commit 7785c50
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion merge/conflict.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func ConflictsFromManagers(sets fieldpath.ManagedFields) Conflicts {
set.Set().Iterate(func(p fieldpath.Path) {
conflicts = append(conflicts, Conflict{
Manager: manager,
Path: p,
Path: p.Copy(),
})
})
}
Expand Down
19 changes: 19 additions & 0 deletions merge/conflict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,22 @@ func TestToSet(t *testing.T) {
t.Fatalf("expected\n%v\n, but got\n%v\n", expected, actual)
}
}

func TestConflictsFromManagers(t *testing.T) {
got := merge.ConflictsFromManagers(fieldpath.ManagedFields{
"Bob": fieldpath.NewVersionedSet(
_NS(
_P("obj", "template", "obj", "list", _KBF("name", "a"), "id"),
_P("obj", "template", "obj", "list", _KBF("name", "a"), "key"),
),
"v1",
false,
),
})
wanted := `conflicts with "Bob":
- .obj.template.obj.list[name="a"].id
- .obj.template.obj.list[name="a"].key`
if got.Error() != wanted {
t.Errorf("Got %v, wanted %v", got.Error(), wanted)
}
}

0 comments on commit 7785c50

Please sign in to comment.