Skip to content

Commit c3bfecf

Browse files
authored
Allowing capitals in topic regex (#418)
Fix regarding support case 00098704 Fixes #419
1 parent b56f2ac commit c3bfecf

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

internal/provider/resource_streaming_topic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ func (t *StreamingTopicResourceModel) generateStreamingTopicID() string {
542542

543543
var (
544544
streamingTopicIDPattern = `^([a-z][a-z0-9-]*):(persistent|non-persistent)://` +
545-
`([a-z][a-z0-9-]*)/([a-z][a-z0-9-]*)/([a-z][a-z0-9-._]*)$`
545+
`([a-z][a-z0-9-]*)/([a-z][a-z0-9-]*)/([a-zA-Z][a-zA-Z0-9-._]*)$`
546546
streamingTopicIDRegex = regexp.MustCompile(streamingTopicIDPattern)
547547
)
548548

internal/provider/resource_streaming_topic_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,20 @@ func TestParseStreamingTopicID(t *testing.T) {
9393
assert.True(t, topic.Partitioned.ValueBool())
9494
assert.Equal(t, "non-persistent://my-tenant/my-namespace/topic1", topic.getTopicFQN())
9595
}
96+
97+
func TestTopicNameValidation(t *testing.T) {
98+
topicID := "my-cluster:persistent://my-tenant/my-namespace/this.Topic-is_valid123-DLQ"
99+
topic, err := parseStreamingTopicID(topicID)
100+
assert.Nil(t, err)
101+
assert.Equal(t, "this.Topic-is_valid123-DLQ", topic.Topic.ValueString())
102+
103+
invalidTopics := []string{
104+
"my-cluster:persistent://my-tenant/my-namespace/this.Topic-isnt$valid123",
105+
"my-cluster:persistent://my-tenant/my-namespace/1this.Topic-isnt_valid123",
106+
"my-cluster:persistent://my-tenant/my-namespace/this.Topic-isnt_valid123+",
107+
}
108+
for _, topicID := range invalidTopics {
109+
topic, err = parseStreamingTopicID(topicID)
110+
assert.NotNil(t, err)
111+
}
112+
}

0 commit comments

Comments
 (0)