Skip to content

Commit

Permalink
feat(mnq): fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jremy42 committed Dec 10, 2024
1 parent 90cdde4 commit 9828642
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
8 changes: 4 additions & 4 deletions internal/services/mnq/sns_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func ResourceMNQSNSTopicCreate(ctx context.Context, d *schema.ResourceData, m in
return diag.FromErr(fmt.Errorf("expected sns to be enabled for given project, go %q", snsInfo.Status))
}

snsClient, _, err := SNSClientWithRegion(nil, m, d)
snsClient, _, err := SNSClientWithRegion(ctx, m, d)
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func ResourceMNQSNSTopicCreate(ctx context.Context, d *schema.ResourceData, m in
}

func ResourceMNQSNSTopicRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
snsClient, _, err := SNSClientWithRegion(nil, m, d)
snsClient, _, err := SNSClientWithRegion(ctx, m, d)
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -173,7 +173,7 @@ func ResourceMNQSNSTopicRead(ctx context.Context, d *schema.ResourceData, m inte
}

func ResourceMNQSNSTopicUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
snsClient, _, err := SNSClientWithRegion(nil, m, d)
snsClient, _, err := SNSClientWithRegion(ctx, m, d)
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -220,7 +220,7 @@ func ResourceMNQSNSTopicUpdate(ctx context.Context, d *schema.ResourceData, m in
}

func ResourceMNQSNSTopicDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
snsClient, _, err := SNSClientWithRegion(nil, m, d)
snsClient, _, err := SNSClientWithRegion(ctx, m, d)
if err != nil {
return diag.FromErr(err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/mnq/sns_topic_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func ResourceMNQSNSTopicSubscriptionCreate(ctx context.Context, d *schema.Resour
return diag.FromErr(fmt.Errorf("expected sns to be enabled for given project, go %q", snsInfo.Status))
}

snsClient, _, err := SNSClientWithRegion(nil, m, d)
snsClient, _, err := SNSClientWithRegion(ctx, m, d)
if err != nil {
return diag.FromErr(err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/services/mnq/sqs_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,13 @@ func ResourceMNQSQSQueueCreate(ctx context.Context, d *schema.ResourceData, m in
Attributes: attributes,
QueueName: scw.StringPtr(queueName),
}
_, err = transport.RetryWhenAWSErrCodeEqualsV2(ctx, []string{"AWS.SimpleQueueService.QueueDeletedRecently"}, &transport.RetryWhenConfig[*sqs.CreateQueueOutput]{
_, err = transport.RetryWhenAWSErrCodeEquals(ctx, []string{"AWS.SimpleQueueService.QueueDeletedRecently"}, &transport.RetryWhenConfig[*sqs.CreateQueueOutput]{
Timeout: d.Timeout(schema.TimeoutCreate),
Interval: defaultMNQQueueRetryInterval,
Function: func() (*sqs.CreateQueueOutput, error) {
return sqsClient.CreateQueue(ctx, input)
},
})

if err != nil {
return diag.Errorf("failed to create SQS Queue: %s", err)
}
Expand Down
9 changes: 1 addition & 8 deletions internal/transport/retry_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@ import (
"errors"
"time"

"github.com/hashicorp/aws-sdk-go-base/tfawserr"
tfawserrV2 "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr"
"github.com/hashicorp/aws-sdk-go-base/v2/tfawserr"
)

func RetryWhenAWSErrCodeEqualsV2[T any](ctx context.Context, codes []string, config *RetryWhenConfig[T]) (T, error) {
return retryWhen(ctx, config, func(err error) bool {
return tfawserrV2.ErrCodeEquals(err, codes...)
})
}

// RetryWhenAWSErrCodeEquals retries a function when it returns a specific AWS error
func RetryWhenAWSErrCodeEquals[T any](ctx context.Context, codes []string, config *RetryWhenConfig[T]) (T, error) { //nolint: ireturn
return retryWhen(ctx, config, func(err error) bool {
Expand Down

0 comments on commit 9828642

Please sign in to comment.