Skip to content

Commit

Permalink
fix: use same API to pull Consumer Groups from Konnect and Kong
Browse files Browse the repository at this point in the history
  • Loading branch information
GGabriele committed Jul 26, 2023
1 parent 24ef372 commit 6bfd16b
Showing 1 changed file with 1 addition and 33 deletions.
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

0 comments on commit 6bfd16b

Please sign in to comment.