Skip to content

Commit

Permalink
fix: adds 2 http retries to humanitec client requests
Browse files Browse the repository at this point in the history
  • Loading branch information
astromechza committed Sep 12, 2024
1 parent 65999d1 commit 25b9dce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/humanitec/humanitec-go-autogen v0.0.0-20240620130303-6979d29fd1fa
github.com/justinrixx/retryhttp v1.0.1
github.com/stretchr/testify v1.9.0
sigs.k8s.io/yaml v1.4.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
github.com/justinrixx/retryhttp v1.0.1 h1:hTCOBTOcmzR3/W7weMB2YBOl1LlQrqVPIZPAf40p+14=
github.com/justinrixx/retryhttp v1.0.1/go.mod h1:vGs79/0Ut0//fmOGS9HAgI/IbZS6oFV3jFOTCxGEXt0=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down
5 changes: 4 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/justinrixx/retryhttp"

"github.com/humanitec/humanitec-go-autogen"
)

Expand Down Expand Up @@ -177,9 +179,10 @@ func (p *HumanitecProvider) Configure(ctx context.Context, req provider.Configur
}
doer = &http.Client{Transport: tr}
} else {
doer = &http.Client{}
doer = &http.Client{Transport: http.DefaultTransport}
}

doer.Transport = retryhttp.New(retryhttp.WithTransport(doer.Transport))
client, err := NewHumanitecClient(apiPrefix, token, p.version, doer)
if err != nil {
resp.Diagnostics.AddError("Unable to create Humanitec client", err.Error())
Expand Down

0 comments on commit 25b9dce

Please sign in to comment.