github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/builtin/providers/google/dns_change.go (about)

     1  package google
     2  
     3  import (
     4  	"google.golang.org/api/dns/v1"
     5  
     6  	"github.com/hashicorp/terraform/helper/resource"
     7  )
     8  
     9  type DnsChangeWaiter struct {
    10  	Service     *dns.Service
    11  	Change      *dns.Change
    12  	Project     string
    13  	ManagedZone string
    14  }
    15  
    16  func (w *DnsChangeWaiter) RefreshFunc() resource.StateRefreshFunc {
    17  	return func() (interface{}, string, error) {
    18  		var chg *dns.Change
    19  		var err error
    20  
    21  		chg, err = w.Service.Changes.Get(
    22  			w.Project, w.ManagedZone, w.Change.Id).Do()
    23  
    24  		if err != nil {
    25  			return nil, "", err
    26  		}
    27  
    28  		return chg, chg.Status, nil
    29  	}
    30  }
    31  
    32  func (w *DnsChangeWaiter) Conf() *resource.StateChangeConf {
    33  	return &resource.StateChangeConf{
    34  		Pending: []string{"pending"},
    35  		Target:  "done",
    36  		Refresh: w.RefreshFunc(),
    37  	}
    38  }