Skip to content

Commit

Permalink
fix: update target in-place
Browse files Browse the repository at this point in the history
Targets in Kong were immutable. They were changed to be mutable a few
months ago but we can't break compatibility.

If target's weight was changed, it resulted in the following:
- diff is detected, an update is issued
- update operations are translated into delete then create, the ID
changes
- the update is then reflected into go-memdb, because the ID is new,
state package emits an error that it can't update an entity that it
didn't previously have

This patch ensures that ID across update remains the same.

The tests for this is here: Kong/go-kong#85
  • Loading branch information
hbagdi committed Aug 27, 2021
1 parent 74f9e54 commit 1bfde5f
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion types/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (s *targetCRUD) Update(ctx context.Context, arg ...crud.Arg) (crud.Arg, err
if err != nil {
return nil, err
}
target.ID = nil
createdTarget, err := s.client.Targets.Create(ctx,
target.Upstream.ID, &target.Target)
if err != nil {
Expand Down

0 comments on commit 1bfde5f

Please sign in to comment.