opentofu/builtin/providers/triton/utils.go
James Nugent e70764f64d provider/triton: New provider for Joyent Triton
This brings across the following resources for Triton from the
joyent/triton-terraform repository, and converts them to the canonical
Terraform style, introducing Terraform-style documentation and
acceptance tests which run against the live API rather than the local
APIs:

- triton_firewall_rule
- triton_machine
- triton_key
2016-03-20 20:15:17 +00:00

31 lines
449 B
Go

package triton
import (
"errors"
"time"
)
var (
// ErrTimeout is returned when waiting for state change
ErrTimeout = errors.New("timed out while waiting for resource change")
)
func waitFor(f func() (bool, error), every, timeout time.Duration) error {
start := time.Now()
for time.Since(start) <= timeout {
stop, err := f()
if err != nil {
return err
}
if stop {
return nil
}
time.Sleep(every)
}
return ErrTimeout
}