Skip to content

Commit

Permalink
Merge pull request #34 from parabolala/main
Browse files Browse the repository at this point in the history
Fix error handling of non-retriable HTTP errors
  • Loading branch information
cullenmcdermott committed Jul 4, 2023
2 parents 8ef106f + e28edd8 commit 60d0890
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions internal/provider/resource_dns_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package provider
import (
"context"
"fmt"
"strconv"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/provider"
Expand All @@ -12,9 +16,6 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/nrdcg/porkbun"
"golang.org/x/exp/slices"
"strconv"
"strings"
"time"
)

// Ensure provider defined types fully satisfy framework interfaces
Expand Down Expand Up @@ -290,7 +291,7 @@ func retry[T any](attempts int, sleep int, f func() (T, error)) (result T, err e
return result, fmt.Errorf("cannot be retried: %s", status.Error())
}
}
servererr, ok := err.(porkbun.ServerError)
servererr, ok := err.(*porkbun.ServerError)
if ok {
if !isRetryable(servererr.StatusCode) {
return result, fmt.Errorf("received error is not retryable: %s", servererr.Error())
Expand All @@ -310,7 +311,7 @@ func retrySingleReturn(attempts int, sleep int, f func() error) (err error) {
if err == nil {
return nil
}
err, ok := err.(porkbun.ServerError)
err, ok := err.(*porkbun.ServerError)
if ok {
if !isRetryable(err.StatusCode) {
return fmt.Errorf("received error is not retryable: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {

opts := providerserver.ServeOpts{
// TODO: Update this string with the published name of your provider.
Address: "registry.terraform.io/hashicorp/scaffolding",
Address: "registry.terraform.io/cullenmcdermott/porkbun",
Debug: debug,
}

Expand Down

0 comments on commit 60d0890

Please sign in to comment.