Skip to content

Commit d59dbbe

Browse files
retry on abilities call for sdk v2 config
1 parent b26b489 commit d59dbbe

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pagerduty/config.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/PagerDuty/terraform-provider-pagerduty/util"
1212
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1314
"github.com/heimweh/go-pagerduty/pagerduty"
1415
"github.com/heimweh/go-pagerduty/persistentconfig"
1516
)
@@ -112,9 +113,20 @@ func (c *Config) Client() (*pagerduty.Client, error) {
112113
}
113114

114115
if !c.SkipCredsValidation {
115-
// Validate the credentials by calling the abilities endpoint,
116-
// if we get a 401 response back we return an error to the user
117-
if err := client.ValidateAuth(); err != nil {
116+
err := retry.Retry(2*time.Minute, func() *retry.RetryError {
117+
if err := client.ValidateAuth(); err != nil {
118+
return retry.NonRetryableError(err)
119+
}
120+
121+
// Validate the credentials by calling the abilities endpoint,
122+
// if we get a 401 response back we return an error to the user
123+
if err := client.ValidateAuth(); err != nil {
124+
return retry.RetryableError(err)
125+
}
126+
return nil
127+
})
128+
129+
if err != nil {
118130
return nil, fmt.Errorf(fmt.Sprintf("%s\n%s", err, invalidCreds))
119131
}
120132
}

0 commit comments

Comments
 (0)