Skip to content

Commit

Permalink
feat(kafkatopic): creation simplification (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-savciuc authored Sep 28, 2023
1 parent 146cff7 commit fb1e435
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 81 deletions.
20 changes: 7 additions & 13 deletions internal/sdkprovider/service/kafkatopic/kafka_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,13 @@ func resourceKafkaTopicCreate(ctx context.Context, d *schema.ResourceData, m int
Tags: getTags(d),
}

w := &kafkaTopicCreateWaiter{
Context: ctx,
Client: m.(*aiven.Client),
Project: project,
ServiceName: serviceName,
CreateRequest: createRequest,
}

timeout := d.Timeout(schema.TimeoutCreate)

// nolint:staticcheck // TODO: Migrate to helper/retry package to avoid deprecated WaitForStateContext.
_, err = w.Conf(timeout).WaitForStateContext(ctx)
if err != nil {
err = m.(*aiven.Client).KafkaTopics.Create(
ctx,
project,
serviceName,
createRequest,
)
if err != nil && !aiven.IsAlreadyExists(err) {
return diag.FromErr(err)
}

Expand Down
4 changes: 4 additions & 0 deletions internal/sdkprovider/service/kafkatopic/kafka_topic_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ func (t *kafkaTopicCache) GetV1List(projectName, serviceName string) []string {
}

// DeleteTopicFromCache Invalidates cache for the topic
// This function only exists to pass acceptance tests. Cache invalidation
// happens automatically in Terraform when used in the real-life world between
// each subsequent operation. However, during the acceptance test execution,
// we need to mimic the cache invalidation mechanism by calling this function.
func DeleteTopicFromCache(projectName, serviceName, topicName string) {
t := getTopicCache()
t.Lock()
Expand Down
68 changes: 0 additions & 68 deletions internal/sdkprovider/service/kafkatopic/kafka_topic_create.go

This file was deleted.

0 comments on commit fb1e435

Please sign in to comment.