Skip to content

Commit

Permalink
Allowing capitals in topic regex (#418)
Browse files Browse the repository at this point in the history
Fix regarding support case 00098704

Fixes #419
  • Loading branch information
Samreay authored Jan 14, 2025
1 parent b56f2ac commit c3bfecf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/provider/resource_streaming_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func (t *StreamingTopicResourceModel) generateStreamingTopicID() string {

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

Expand Down
17 changes: 17 additions & 0 deletions internal/provider/resource_streaming_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,20 @@ func TestParseStreamingTopicID(t *testing.T) {
assert.True(t, topic.Partitioned.ValueBool())
assert.Equal(t, "non-persistent://my-tenant/my-namespace/topic1", topic.getTopicFQN())
}

func TestTopicNameValidation(t *testing.T) {
topicID := "my-cluster:persistent://my-tenant/my-namespace/this.Topic-is_valid123-DLQ"
topic, err := parseStreamingTopicID(topicID)
assert.Nil(t, err)
assert.Equal(t, "this.Topic-is_valid123-DLQ", topic.Topic.ValueString())

invalidTopics := []string{
"my-cluster:persistent://my-tenant/my-namespace/this.Topic-isnt$valid123",
"my-cluster:persistent://my-tenant/my-namespace/1this.Topic-isnt_valid123",
"my-cluster:persistent://my-tenant/my-namespace/this.Topic-isnt_valid123+",
}
for _, topicID := range invalidTopics {
topic, err = parseStreamingTopicID(topicID)
assert.NotNil(t, err)
}
}

0 comments on commit c3bfecf

Please sign in to comment.