From 1318eb399ff6ee5e8d1004cf980ba43b5d899d9d Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 4 Feb 2026 13:48:42 +0530 Subject: [PATCH 1/3] fix: added validation for --skip-consumers with default lookup consumer and consumer-groups --- cmd/common.go | 7 +++++ tests/integration/sync_test.go | 19 ++++++++++++ ...ault-look-up-tag-with-consumer-groups.yaml | 29 +++++++++++++++++++ .../default-look-up-tag-with-consumers.yaml | 29 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumer-groups.yaml create mode 100644 tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumers.yaml diff --git a/cmd/common.go b/cmd/common.go index 1a0e80f14..4180454be 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -155,6 +155,13 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism, if err != nil { return err } + + if dumpConfig.SkipConsumers && targetContent.Info != nil && + targetContent.Info.LookUpSelectorTags != nil && + (targetContent.Info.LookUpSelectorTags.Consumers != nil || targetContent.Info.LookUpSelectorTags.ConsumerGroups != nil) { + return errors.New("cannot use --skip-consumers with default lookup tags for consumers or consumer groups") + } + if dumpConfig.SkipConsumers { targetContent.Consumers = []file.FConsumer{} targetContent.ConsumerGroups = []file.FConsumerGroupObject{} diff --git a/tests/integration/sync_test.go b/tests/integration/sync_test.go index e02dd4e2e..9401f99f0 100644 --- a/tests/integration/sync_test.go +++ b/tests/integration/sync_test.go @@ -8597,6 +8597,25 @@ func Test_Sync_SkipConsumersWithConsumerGroups_Konnect(t *testing.T) { }) } +func Test_Sync_SkipConsumersWithDefaultLookUp_ConsumersAndConsumerGroup_Tag(t *testing.T) { + runWhenEnterpriseOrKonnect(t, ">=3.0.0") + setup(t) + + ctx := context.Background() + + t.Run("--skip-consumers-with-default-lookup-consumer flag set", func(t *testing.T) { + err := sync(ctx, "testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumers.yaml", "--skip-consumers") + require.Error(t, err) + assert.ErrorContains(t, err, "cannot use --skip-consumers with default lookup tags for consumers or consumer groups") + }) + + t.Run("--skip-consumers-with-default-lookup-consumer-group flag set", func(t *testing.T) { + err := sync(ctx, "testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumer-groups.yaml", "--skip-consumers") + require.Error(t, err) + assert.ErrorContains(t, err, "cannot use --skip-consumers with default lookup tags for consumers or consumer groups") + }) +} + func Test_Sync_Partials_Plugins(t *testing.T) { runWhen(t, "enterprise", ">=3.10.0") diff --git a/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumer-groups.yaml b/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumer-groups.yaml new file mode 100644 index 000000000..961c1e6ab --- /dev/null +++ b/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumer-groups.yaml @@ -0,0 +1,29 @@ +_format_version: "3.0" +_info: + select_tags: + - my-service + default_lookup_tags: + consumer_groups: + - my-consumer-group +services: + - name: my-service + host: example.com + port: 443 + protocol: https + path: /api + tags: + - my-service +plugins: + - name: rate-limiting-advanced + consumer: my-consumer-username + service: my-service + config: + limit: + - 30000 + window_size: + - 60 + strategy: local + window_type: fixed + namespace: my-namespace + tags: + - my-service \ No newline at end of file diff --git a/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumers.yaml b/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumers.yaml new file mode 100644 index 000000000..1cc1394bb --- /dev/null +++ b/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumers.yaml @@ -0,0 +1,29 @@ +_format_version: "3.0" +_info: + select_tags: + - my-service + default_lookup_tags: + consumers: + - MyConsumerTag +services: + - name: my-service + host: example.com + port: 443 + protocol: https + path: /api + tags: + - my-service +plugins: + - name: rate-limiting-advanced + consumer: my-consumer-username + service: my-service + config: + limit: + - 30000 + window_size: + - 60 + strategy: local + window_type: fixed + namespace: my-namespace + tags: + - my-service \ No newline at end of file From 9be79ce7e6849c9496d49ade73c9ebd3ee17624b Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 4 Feb 2026 13:56:02 +0530 Subject: [PATCH 2/3] fix: resolved linting issue --- cmd/common.go | 6 +++--- tests/integration/sync_test.go | 4 ++-- ...p-tag-with-consumer-groups.yaml => consumer-groups.yaml} | 0 ...fault-look-up-tag-with-consumers.yaml => consumers.yaml} | 0 4 files changed, 5 insertions(+), 5 deletions(-) rename tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/{default-look-up-tag-with-consumer-groups.yaml => consumer-groups.yaml} (100%) rename tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/{default-look-up-tag-with-consumers.yaml => consumers.yaml} (100%) diff --git a/cmd/common.go b/cmd/common.go index 4180454be..bf4fda271 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -156,9 +156,9 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism, return err } - if dumpConfig.SkipConsumers && targetContent.Info != nil && - targetContent.Info.LookUpSelectorTags != nil && - (targetContent.Info.LookUpSelectorTags.Consumers != nil || targetContent.Info.LookUpSelectorTags.ConsumerGroups != nil) { + if dumpConfig.SkipConsumers && targetContent.Info != nil && targetContent.Info.LookUpSelectorTags != nil && + (targetContent.Info.LookUpSelectorTags.Consumers != nil || + targetContent.Info.LookUpSelectorTags.ConsumerGroups != nil) { return errors.New("cannot use --skip-consumers with default lookup tags for consumers or consumer groups") } diff --git a/tests/integration/sync_test.go b/tests/integration/sync_test.go index 9401f99f0..2f87cbdd7 100644 --- a/tests/integration/sync_test.go +++ b/tests/integration/sync_test.go @@ -8604,13 +8604,13 @@ func Test_Sync_SkipConsumersWithDefaultLookUp_ConsumersAndConsumerGroup_Tag(t *t ctx := context.Background() t.Run("--skip-consumers-with-default-lookup-consumer flag set", func(t *testing.T) { - err := sync(ctx, "testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumers.yaml", "--skip-consumers") + err := sync(ctx, "testdata/sync/049-skip-consumers-default-lookup-tags/consumers.yaml", "--skip-consumers") require.Error(t, err) assert.ErrorContains(t, err, "cannot use --skip-consumers with default lookup tags for consumers or consumer groups") }) t.Run("--skip-consumers-with-default-lookup-consumer-group flag set", func(t *testing.T) { - err := sync(ctx, "testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumer-groups.yaml", "--skip-consumers") + err := sync(ctx, "testdata/sync/049-skip-consumers-default-lookup-tags/consumer-groups.yaml", "--skip-consumers") require.Error(t, err) assert.ErrorContains(t, err, "cannot use --skip-consumers with default lookup tags for consumers or consumer groups") }) diff --git a/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumer-groups.yaml b/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/consumer-groups.yaml similarity index 100% rename from tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumer-groups.yaml rename to tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/consumer-groups.yaml diff --git a/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumers.yaml b/tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/consumers.yaml similarity index 100% rename from tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/default-look-up-tag-with-consumers.yaml rename to tests/integration/testdata/sync/049-skip-consumers-default-lookup-tags/consumers.yaml From 1e4e1b7f523067c41d148b261e099afbde20863f Mon Sep 17 00:00:00 2001 From: shivay Date: Wed, 4 Feb 2026 16:52:04 +0530 Subject: [PATCH 3/3] fix: resolved review comment. --- cmd/common.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/common.go b/cmd/common.go index bf4fda271..2ce8a3528 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -156,10 +156,9 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism, return err } - if dumpConfig.SkipConsumers && targetContent.Info != nil && targetContent.Info.LookUpSelectorTags != nil && - (targetContent.Info.LookUpSelectorTags.Consumers != nil || - targetContent.Info.LookUpSelectorTags.ConsumerGroups != nil) { - return errors.New("cannot use --skip-consumers with default lookup tags for consumers or consumer groups") + err = validateSkipConsumersWithLookupTags(targetContent) + if err != nil { + return err } if dumpConfig.SkipConsumers { @@ -458,6 +457,15 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism, return nil } +func validateSkipConsumersWithLookupTags(targetContent *file.Content) error { + if dumpConfig.SkipConsumers && targetContent.Info != nil && targetContent.Info.LookUpSelectorTags != nil && + (targetContent.Info.LookUpSelectorTags.Consumers != nil || + targetContent.Info.LookUpSelectorTags.ConsumerGroups != nil) { + return errors.New("cannot use --skip-consumers with default lookup tags for consumers or consumer groups") + } + return nil +} + func addUniqueConsumersInTargetContent(targetContent *file.Content, consumers []*kong.Consumer, consumerGroupObject *file.FConsumerGroupObject, consumersExistInTargetContent bool,