2015-04-30 07:32:34 +02:00
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
2016-08-08 02:36:27 +02:00
|
|
|
"time"
|
|
|
|
|
2015-04-30 07:32:34 +02:00
|
|
|
"google.golang.org/api/dns/v1"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
)
|
|
|
|
|
|
|
|
type DnsChangeWaiter struct {
|
2015-06-24 07:31:24 +02:00
|
|
|
Service *dns.Service
|
|
|
|
Change *dns.Change
|
|
|
|
Project string
|
2015-04-30 07:32:34 +02:00
|
|
|
ManagedZone string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *DnsChangeWaiter) RefreshFunc() resource.StateRefreshFunc {
|
|
|
|
return func() (interface{}, string, error) {
|
|
|
|
var chg *dns.Change
|
|
|
|
var err error
|
|
|
|
|
|
|
|
chg, err = w.Service.Changes.Get(
|
|
|
|
w.Project, w.ManagedZone, w.Change.Id).Do()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
return chg, chg.Status, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *DnsChangeWaiter) Conf() *resource.StateChangeConf {
|
2016-08-08 02:36:27 +02:00
|
|
|
state := &resource.StateChangeConf{
|
2015-04-30 07:32:34 +02:00
|
|
|
Pending: []string{"pending"},
|
2016-01-21 02:20:41 +01:00
|
|
|
Target: []string{"done"},
|
2015-04-30 07:32:34 +02:00
|
|
|
Refresh: w.RefreshFunc(),
|
|
|
|
}
|
2016-08-08 02:36:27 +02:00
|
|
|
state.Delay = 10 * time.Second
|
|
|
|
state.Timeout = 10 * time.Minute
|
|
|
|
state.MinTimeout = 2 * time.Second
|
|
|
|
return state
|
|
|
|
|
2015-04-30 07:32:34 +02:00
|
|
|
}
|