github.com/mohanarpit/terraform@v0.6.16-0.20160909104007-291f29853544/builtin/providers/google/dns_change.go (about) 1 package google 2 3 import ( 4 "time" 5 6 "google.golang.org/api/dns/v1" 7 8 "github.com/hashicorp/terraform/helper/resource" 9 ) 10 11 type DnsChangeWaiter struct { 12 Service *dns.Service 13 Change *dns.Change 14 Project string 15 ManagedZone string 16 } 17 18 func (w *DnsChangeWaiter) RefreshFunc() resource.StateRefreshFunc { 19 return func() (interface{}, string, error) { 20 var chg *dns.Change 21 var err error 22 23 chg, err = w.Service.Changes.Get( 24 w.Project, w.ManagedZone, w.Change.Id).Do() 25 26 if err != nil { 27 return nil, "", err 28 } 29 30 return chg, chg.Status, nil 31 } 32 } 33 34 func (w *DnsChangeWaiter) Conf() *resource.StateChangeConf { 35 state := &resource.StateChangeConf{ 36 Pending: []string{"pending"}, 37 Target: []string{"done"}, 38 Refresh: w.RefreshFunc(), 39 } 40 state.Delay = 10 * time.Second 41 state.Timeout = 10 * time.Minute 42 state.MinTimeout = 2 * time.Second 43 return state 44 45 }