mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-09 23:54:17 -06:00
e70764f64d
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
31 lines
449 B
Go
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
|
|
}
|