Skip to content

Commit

Permalink
fix: fixing consumer-group related dump config for deck.
Browse files Browse the repository at this point in the history
With changes added in go-kong, to skip
listing consumers while doing a GET call
on a consumer_group, dump config with gw
3.9+ starting showing issues. Associations
between a consumer and consumer-group were
missing. Thus, we are pushing the no listing
consumers feature behind a flag for now,
applicable only for dump command as a
starting point.
  • Loading branch information
Prashansa-K committed Jan 8, 2025
1 parent caaf75c commit dd60952
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/gateway_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ configure Kong.`,
false, "assume `yes` to prompts and run non-interactively.")
dumpCmd.Flags().BoolVar(&dumpConfig.SkipCACerts, "skip-ca-certificates",
false, "do not dump CA certificates.")
dumpCmd.Flags().BoolVar(&dumpConfig.SkipConsumersWithConsumerGroups, "skip-consumers-with-consumer-groups",

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / build

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / lint

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)) (typecheck)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / lint

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)) (typecheck)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / lint

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups) (typecheck)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / lint

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)) (typecheck)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong:3.4)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong:3.6)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong/kong:master)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong:2.8)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong/kong-gateway:2.8)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / test

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong/kong-gateway:3.5)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong/kong-gateway:3.4)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong:3.7)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong:3.5)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong:3.8)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong/kong-gateway:3.8)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)

Check failure on line 191 in cmd/gateway_dump.go

View workflow job for this annotation

GitHub Actions / integration (kong/kong-gateway:3.6)

dumpConfig.SkipConsumersWithConsumerGroups undefined (type dump.Config has no field or method SkipConsumersWithConsumerGroups)
false, "do not show the association between consumer and consumer-group.\n"+
"If set to true, deck skips listing consumers with consumer-groups,\n"+
"thus gaining some performance with large configs.")
if deprecated {
dumpCmd.Flags().StringVarP(&dumpCmdKongStateFileDeprecated, "output-file", "o",
fileOutDefault, "file to which to write Kong's configuration."+
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,29 @@ func Test_Dump_FilterChains(t *testing.T) {
})
}
}

func Test_SkipConsumersWithConsumerGroups(t *testing.T) {
runWhen(t, "enterprise", ">=3.9.0")
setup(t)

require.NoError(t, sync("testdata/dump/004-skip-consumers-with-consumer-groups/kong.yaml"))

// With flag set
var output string
flags := []string{"-o", "-", "--skip-consumers-with-consumer-groups"}
output, err := dump(flags...)
assert.NoError(t, err)

expected, err := readFile("testdata/dump/004-skip-consumers-with-consumer-groups/expected-with-flag.yaml")
assert.NoError(t, err)
assert.Equal(t, expected, output)

// Without flag set - default behaviour
flags = []string{"-o", "-"}
output, err = dump(flags...)
assert.NoError(t, err)

expected, err = readFile("testdata/dump/004-skip-consumers-with-consumer-groups/expected-without-flag.yaml")
assert.NoError(t, err)
assert.Equal(t, expected, output)
}
4 changes: 2 additions & 2 deletions tests/integration/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func setup(t *testing.T) {

func sync(kongFile string, opts ...string) error {
deckCmd := cmd.NewRootCmd()
args := []string{"sync", "-s", kongFile}
args := []string{"gateway", "sync", kongFile}
if len(opts) > 0 {
args = append(args, opts...)
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func diff(kongFile string, opts ...string) (string, error) {

func dump(opts ...string) (string, error) {
deckCmd := cmd.NewRootCmd()
args := []string{"dump"}
args := []string{"gateway", "dump"}
if len(opts) > 0 {
args = append(args, opts...)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
_format_version: "3.0"
consumer_groups:
- name: gold
tags:
- tag1
- tag2
- name: silver
tags:
- tag1
- tag3
consumers:
- username: bar
- username: baz
- username: foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
_format_version: "3.0"
consumer_groups:
- name: gold
tags:
- tag1
- tag2
- name: silver
tags:
- tag1
- tag3
consumers:
- groups:
- name: silver
tags:
- tag1
- tag3
username: bar
- groups:
- name: silver
tags:
- tag1
- tag3
username: baz
- groups:
- name: gold
tags:
- tag1
- tag2
username: foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
_format_version: "3.0"
consumer_groups:
- name: silver
tags:
- tag1
- tag3
- name: gold
tags:
- tag1
- tag2
consumers:
- username: foo
groups:
- name: gold
- username: bar
groups:
- name: silver
- username: baz
groups:
- name: silver

0 comments on commit dd60952

Please sign in to comment.