Skip to content

Commit 0afa18d

Browse files
authored
fead: add sequence if group id does not have it (#73)
* feat: add sequence if group id does not have it" * refactor: use fmt package * fix: lint issue
1 parent 44b26ce commit 0afa18d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

modules/firehose/driver_plan.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import (
1717
const SourceKafkaConsumerAutoOffsetReset = "SOURCE_KAFKA_CONSUMER_CONFIG_AUTO_OFFSET_RESET"
1818

1919
var (
20-
suffixRegex = regexp.MustCompile(`^([A-Za-z0-9-]+)-([0-9]+)$`)
21-
errGroupIDFormat = fmt.Errorf("group id must match the format '%s'", suffixRegex)
20+
suffixRegex = regexp.MustCompile(`^([A-Za-z0-9-]+)-([0-9]+)$`)
2221
)
2322

2423
func (fd *firehoseDriver) Plan(_ context.Context, exr module.ExpandedResource, act module.ActionRequest) (*resource.Resource, error) {
@@ -212,7 +211,7 @@ func (fd *firehoseDriver) planReset(exr module.ExpandedResource, act module.Acti
212211
func getNewConsumerGroupID(curGroup string) (string, error) {
213212
matches := suffixRegex.FindStringSubmatch(curGroup)
214213
if expLen := 3; len(matches) != expLen {
215-
return "", errGroupIDFormat
214+
return fmt.Sprintf("%s-1", curGroup), nil
216215
}
217216
prefix, sequence := matches[1], matches[2]
218217

modules/firehose/driver_plan_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ func TestGetNewConsumerGroupID(t *testing.T) {
573573
{
574574
title: "invalid-group-id",
575575
consumerGroupID: "test-firehose-xyz",
576-
want: "",
577-
wantErr: errGroupIDFormat,
576+
want: "test-firehose-xyz-1",
577+
wantErr: nil,
578578
},
579579
{
580580
title: "valid-group-id",

0 commit comments

Comments
 (0)