Skip to content

Commit

Permalink
use withRegion() to superseed any other region configuration if needed (
Browse files Browse the repository at this point in the history
  • Loading branch information
rumenvasilev authored Nov 18, 2024
1 parent f6e3e59 commit 9b46854
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Unreleased

## 0.1.6

FIXES:
* correctly wrap retry errors, so they are recognised as such, instead of generic client error
* region override must use WithRegion() function call so it superseeds any others, including WithDefaultRegion()

## 0.1.5

FIXES:
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/parameter_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ func (d *ParameterDataSource) Read(ctx context.Context, req datasource.ReadReque
// Check if the error is retryable (e.g., rate limiting, network issues)
if isRetryableError(ctx, erri) {
// Return with retryable error, specifying how long to wait before the next retry
return retry.RetryableError(fmt.Errorf("temporary failure: %v, retrying...", erri))
return retry.RetryableError(fmt.Errorf("temporary failure: %w, retrying...", erri))
}

// If it's a permanent error, stop retrying
return retry.NonRetryableError(fmt.Errorf("permanent failure: %v", erri))
return retry.NonRetryableError(fmt.Errorf("permanent failure: %w", erri))
}

// If success, return nil (no retry)
Expand All @@ -182,7 +182,7 @@ func (d *ParameterDataSource) Read(ctx context.Context, req datasource.ReadReque
}

if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read example, got error: %s", err))
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read parameter, got error: %v", err))
return
}

Expand Down
24 changes: 12 additions & 12 deletions internal/provider/parameter_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ func (r *ParameterResource) Create(ctx context.Context, req resource.CreateReque
// Check if the error is retryable (e.g., rate limiting, network issues)
if isRetryableError(ctx, erri) {
// Return with retryable error, specifying how long to wait before the next retry
return retry.RetryableError(fmt.Errorf("temporary failure: %v, retrying...", erri))
return retry.RetryableError(fmt.Errorf("temporary failure: %w, retrying...", erri))
}

// If it's a permanent error, stop retrying
return retry.NonRetryableError(fmt.Errorf("permanent failure: %v", erri))
return retry.NonRetryableError(fmt.Errorf("permanent failure: %w", erri))
}

// If success, return nil (no retry)
Expand Down Expand Up @@ -313,11 +313,11 @@ func (r *ParameterResource) Read(ctx context.Context, req resource.ReadRequest,
// Check if the error is retryable (e.g., rate limiting, network issues)
if isRetryableError(ctx, erri) {
// Return with retryable error, specifying how long to wait before the next retry
return retry.RetryableError(fmt.Errorf("temporary failure: %v, retrying...", erri))
return retry.RetryableError(fmt.Errorf("temporary failure: %w, retrying...", erri))
}

// If it's a permanent error, stop retrying
return retry.NonRetryableError(fmt.Errorf("permanent failure: %v", erri))
return retry.NonRetryableError(fmt.Errorf("permanent failure: %w", erri))
}

// If success, return nil (no retry)
Expand Down Expand Up @@ -362,11 +362,11 @@ func (r *ParameterResource) Read(ctx context.Context, req resource.ReadRequest,
// Check if the error is retryable (e.g., rate limiting, network issues)
if isRetryableError(ctx, erri) {
// Return with retryable error, specifying how long to wait before the next retry
return retry.RetryableError(fmt.Errorf("temporary failure: %v, retrying...", erri))
return retry.RetryableError(fmt.Errorf("temporary failure: %w, retrying...", erri))
}

// If it's a permanent error, stop retrying
return retry.NonRetryableError(fmt.Errorf("permanent failure: %v", erri))
return retry.NonRetryableError(fmt.Errorf("permanent failure: %w", erri))
}

// If success, return nil (no retry)
Expand Down Expand Up @@ -460,11 +460,11 @@ func (r *ParameterResource) Update(ctx context.Context, req resource.UpdateReque
// Check if the error is retryable (e.g., rate limiting, network issues)
if isRetryableError(ctx, erri) {
// Return with retryable error, specifying how long to wait before the next retry
return retry.RetryableError(fmt.Errorf("temporary failure: %v, retrying...", erri))
return retry.RetryableError(fmt.Errorf("temporary failure: %w, retrying...", erri))
}

// If it's a permanent error, stop retrying
return retry.NonRetryableError(fmt.Errorf("permanent failure: %v", erri))
return retry.NonRetryableError(fmt.Errorf("permanent failure: %w", erri))
}

// If success, return nil (no retry)
Expand All @@ -490,11 +490,11 @@ func (r *ParameterResource) Update(ctx context.Context, req resource.UpdateReque
// Check if the error is retryable (e.g., rate limiting, network issues)
if isRetryableError(ctx, erri) {
// Return with retryable error, specifying how long to wait before the next retry
return retry.RetryableError(fmt.Errorf("temporary failure: %v, retrying...", erri))
return retry.RetryableError(fmt.Errorf("temporary failure: %w, retrying...", erri))
}

// If it's a permanent error, stop retrying
return retry.NonRetryableError(fmt.Errorf("permanent failure: %v", erri))
return retry.NonRetryableError(fmt.Errorf("permanent failure: %w", erri))
}

// If success, return nil (no retry)
Expand Down Expand Up @@ -536,11 +536,11 @@ func (r *ParameterResource) Delete(ctx context.Context, req resource.DeleteReque
// Check if the error is retryable (e.g., rate limiting, network issues)
if isRetryableError(ctx, erri) {
// Return with retryable error, specifying how long to wait before the next retry
return retry.RetryableError(fmt.Errorf("temporary failure: %v, retrying...", erri))
return retry.RetryableError(fmt.Errorf("temporary failure: %w, retrying...", erri))
}

// If it's a permanent error, stop retrying
return retry.NonRetryableError(fmt.Errorf("permanent failure: %v", erri))
return retry.NonRetryableError(fmt.Errorf("permanent failure: %w", erri))
}

// If success, return nil (no retry)
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (p *FastSSMProvider) Configure(ctx context.Context, req provider.ConfigureR

// Region
if !data.Region.IsNull() {
options = append(options, config.WithDefaultRegion(data.Region.ValueString()))
options = append(options, config.WithRegion(data.Region.ValueString()))
}

// Static credentials
Expand Down

0 comments on commit 9b46854

Please sign in to comment.