// retrieves an ELB by its ID func resource_digitalocean_droplet_retrieve(id string, client *digitalocean.Client) (*digitalocean.Droplet, error) { // Retrieve the ELB properties for updating the state droplet, err := client.RetrieveDroplet(id) if err != nil { return nil, fmt.Errorf("Error retrieving droplet: %s", err) } return &droplet, nil }
func new_droplet_state_refresh_func(id string, attribute string, client *digitalocean.Client) resource.StateRefreshFunc { return func() (interface{}, string, error) { // Retrieve the ELB properties for updating the state droplet, err := client.RetrieveDroplet(id) if err != nil { log.Printf("Error on retrieving droplet when waiting: %s", err) return nil, "", err } // If the droplet is locked, continue waiting. We can // only perform actions on unlocked droplets, so it's // pointless to look at that status if droplet.IsLocked() == "true" { log.Println("[DEBUG] Droplet is locked, skipping status check and retrying") return nil, "", nil } // Use our mapping to get back a map of the // droplet properties resourceMap, err := resource_digitalocean_droplet_update_state( &terraform.ResourceState{Attributes: map[string]string{}}, &droplet) if err != nil { log.Printf("Error creating map from droplet: %s", err) return nil, "", err } // See if we can access our attribute if attr, ok := resourceMap.Attributes[attribute]; ok { return &droplet, attr, nil } return nil, "", nil } }