Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct inconsistency for multiple consumers with custom_id fields #1037

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

GGabriele
Copy link
Collaborator

This commit corrects a bug preventing consumers with equal Username and CustomID to always be correctly handled by decK.

For example, syncing the following state file works as expected:

$ cat kong.yaml
_format_version: "3.0"
consumers:
- username: TestUser
- username: OtherUser
  custom_id: TestUser
$ deck sync
creating consumer OtherUser
creating consumer TestUser
Summary:
  Created: 2
  Updated: 0
  Deleted: 0

But syncing the following state file (same content as the first one, but with consumers in reverse order) doesn't work:

_format_version: "3.0"
consumers:
- username: OtherUser
  custom_id: TestUser
- username: TestUser
$ deck sync
Error: building state: inserting consumer TestUser: entity already exists

This commit is making sure this bogus inconsistency is corrected.

This commit corrects a bug preventing consumers with equal
`Username` and `CustomID` to always be correctly handled by decK.

For example, syncing the following state file works as expected:

```
$ cat kong.yaml
_format_version: "3.0"
consumers:
- username: TestUser
- username: OtherUser
  custom_id: TestUser
```

```
$ deck sync
creating consumer OtherUser
creating consumer TestUser
Summary:
  Created: 2
  Updated: 0
  Deleted: 0
```

But syncing the following state file (same content as the first one,
but with consumers in reverse order) doesn't work:

```
_format_version: "3.0"
consumers:
- username: OtherUser
  custom_id: TestUser
- username: TestUser
```

```
$ deck sync
Error: building state: inserting consumer TestUser: entity already exists
```

This commit is making sure this bogus inconsistency is corrected.
@GGabriele GGabriele requested a review from a team as a code owner September 27, 2023 10:14
@codecov-commenter
Copy link

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (c155000) 33.65% compared to head (b43cb30) 33.64%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1037      +/-   ##
==========================================
- Coverage   33.65%   33.64%   -0.01%     
==========================================
  Files         101      101              
  Lines       12409    12408       -1     
==========================================
- Hits         4176     4175       -1     
- Misses       7824     7826       +2     
+ Partials      409      407       -2     
Files Coverage Δ
state/consumer.go 71.55% <14.28%> (-0.25%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GGabriele GGabriele merged commit 1ba57a5 into main Sep 27, 2023
35 checks passed
@GGabriele GGabriele deleted the fix/custom_id-consumers branch September 27, 2023 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants