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: use same API to pull Consumer Groups from Konnect and Kong #984

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Table of Contents

- [v1.25.0](#v1250)
- [v1.24.0](#v1240)
- [v1.23.0](#v1230)
- [v1.22.1](#v1221)
Expand Down Expand Up @@ -61,9 +62,9 @@
- [v0.2.0](#v020)
- [v0.1.0](#v010)

## Unreleased
## [v1.25.0]

> Release date: TBD
> Release date: 2023/07/28

### Added

Expand All @@ -75,6 +76,9 @@

### Fixes

- Use same interface to pull Consumer Groups with Kong Gateway and Konnect.
This will help solving the issue of using tags with Consumer Groups when running against Konnect.
[#984](https://github.com/Kong/deck/pull/984)
- Fix Consumers handling when a consumer's `custom_id` is equal to the `username` of another consumer.
[#986](https://github.com/Kong/deck/pull/986)
- Avoid misleading diffs when configuration file has empty tags.
Expand Down Expand Up @@ -1323,6 +1327,7 @@ No breaking changes have been introduced in this release.

Debut release of decK

[v1.25.0]: https://github.com/kong/deck/compare/v1.24.0...v1.25.0
[v1.24.0]: https://github.com/kong/deck/compare/v1.23.0...v1.24.0
[v1.23.0]: https://github.com/kong/deck/compare/v1.22.1...v1.23.0
[v1.22.1]: https://github.com/kong/deck/compare/v1.22.0...v1.22.1
Expand Down
34 changes: 1 addition & 33 deletions dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"net/http"

"github.com/kong/deck/konnect"
"github.com/kong/deck/utils"
"github.com/kong/go-kong/kong"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -71,15 +70,7 @@ func getConsumerGroupsConfiguration(ctx context.Context, group *errgroup.Group,
client *kong.Client, config Config, state *utils.KongRawState,
) {
group.Go(func() error {
var (
err error
consumerGroups []*kong.ConsumerGroupObject
)
if config.KonnectRuntimeGroup != "" {
consumerGroups, err = GetAllKonnectConsumerGroups(ctx, client, config.SelectorTags)
} else {
consumerGroups, err = GetAllConsumerGroups(ctx, client, config.SelectorTags)
}
consumerGroups, err := GetAllConsumerGroups(ctx, client, config.SelectorTags)
if err != nil {
if kong.IsNotFoundErr(err) || kong.IsForbiddenErr(err) {
return nil
Expand Down Expand Up @@ -528,29 +519,6 @@ func GetAllUpstreams(ctx context.Context,
return upstreams, nil
}

// GetAllConsumerGroups queries Konnect for all the ConsumerGroups using client.
func GetAllKonnectConsumerGroups(ctx context.Context,
client *kong.Client, tags []string,
) ([]*kong.ConsumerGroupObject, error) {
var consumerGroupObjects []*kong.ConsumerGroupObject
opt := newOpt(tags)
cgs, err := konnect.ListAllConsumerGroups(ctx, client, opt.Tags)
if err != nil {
return nil, err
}
if err := ctx.Err(); err != nil {
return nil, err
}
for _, cg := range cgs {
r, err := konnect.GetConsumerGroupObject(ctx, client, cg.ID)
if err != nil {
return nil, err
}
consumerGroupObjects = append(consumerGroupObjects, r)
}
return consumerGroupObjects, nil
}

// GetAllConsumerGroups queries Kong for all the ConsumerGroups using client.
func GetAllConsumerGroups(ctx context.Context,
client *kong.Client, tags []string,
Expand Down
18 changes: 9 additions & 9 deletions tests/integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,10 @@ var (
{
Name: kong.String("rate-limiting-advanced"),
Config: kong.Configuration{
"limit": []*int32{int32p(7)},
"retry_after_jitter_max": int32p(1),
"window_size": []*int32{int32p(60)},
"window_type": kong.String("sliding"),
"limit": []any{float64(7)},
"retry_after_jitter_max": float64(1),
"window_size": []any{float64(60)},
"window_type": "sliding",
},
ConsumerGroup: &kong.ConsumerGroup{
ID: kong.String("521a90ad-36cb-4e31-a5db-1d979aee40d1"),
Expand All @@ -652,10 +652,10 @@ var (
{
Name: kong.String("rate-limiting-advanced"),
Config: kong.Configuration{
"limit": []*int32{int32p(10)},
"retry_after_jitter_max": int32p(1),
"window_size": []*int32{int32p(60)},
"window_type": kong.String("sliding"),
"limit": []any{float64(10)},
"retry_after_jitter_max": float64(1),
"window_size": []any{float64(60)},
"window_type": "sliding",
},
ConsumerGroup: &kong.ConsumerGroup{
ID: kong.String("92177268-b134-42f9-909a-36f9d2d3d5e7"),
Expand Down Expand Up @@ -2894,7 +2894,7 @@ func Test_Sync_ConsumerGroups_31(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "enterprise", ">=3.1.0")
runWhen(t, "enterprise", "==3.1.0")
teardown := setup(t)
defer teardown(t)

Expand Down