/
retries.go
39 lines (31 loc) · 1.28 KB
/
retries.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package pluginsdk
import (
"time"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
// TODO: work through and switch these out for WaitForState funcs
// RetryFunc is the function retried until it succeeds.
type RetryFunc = resource.RetryFunc
// RetryError is the required return type of RetryFunc. It forces client code
// to choose whether or not a given error is retryable.
// TODO: deprecate this in the future
type RetryError = resource.RetryError
// Retry is a basic wrapper around StateChangeConf that will just retry
// a function until it no longer returns an error.
func Retry(timeout time.Duration, f RetryFunc) error {
// TODO: deprecate this
// lint:ignore SA1019 SDKv2 migration - staticcheck's own linter directives are currently being ignored under golanci-lint
return resource.Retry(timeout, f) //nolint:staticcheck
}
// RetryableError is a helper to create a RetryError that's retryable from a
// given error.
func RetryableError(err error) *RetryError {
// TODO: deprecate this in the future
return resource.RetryableError(err)
}
// NonRetryableError is a helper to create a RetryError that's _not_ retryable
// from a given error.
func NonRetryableError(err error) *RetryError {
// TODO: deprecate this in the future
return resource.NonRetryableError(err)
}