providers/digitalocean: style
This commit is contained in:
parent
9b8b38cbb1
commit
9a8cb2c526
|
@ -151,7 +151,6 @@ func resourceDigitalOceanDropletCreate(d *schema.ResourceData, meta interface{})
|
||||||
log.Printf("[INFO] Droplet ID: %s", d.Id())
|
log.Printf("[INFO] Droplet ID: %s", d.Id())
|
||||||
|
|
||||||
_, err = WaitForDropletAttribute(d, "active", []string{"new"}, "status", meta)
|
_, err = WaitForDropletAttribute(d, "active", []string{"new"}, "status", meta)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"Error waiting for droplet (%s) to become ready: %s", d.Id(), err)
|
"Error waiting for droplet (%s) to become ready: %s", d.Id(), err)
|
||||||
|
@ -165,7 +164,6 @@ func resourceDigitalOceanDropletRead(d *schema.ResourceData, meta interface{}) e
|
||||||
|
|
||||||
// Retrieve the droplet properties for updating the state
|
// Retrieve the droplet properties for updating the state
|
||||||
droplet, err := client.RetrieveDroplet(d.Id())
|
droplet, err := client.RetrieveDroplet(d.Id())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error retrieving droplet: %s", err)
|
return fmt.Errorf("Error retrieving droplet: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -219,7 +217,6 @@ func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{})
|
||||||
|
|
||||||
// Wait for power off
|
// Wait for power off
|
||||||
_, err = WaitForDropletAttribute(d, "off", []string{"active"}, "status", client)
|
_, err = WaitForDropletAttribute(d, "off", []string{"active"}, "status", client)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"Error waiting for droplet (%s) to become powered off: %s", d.Id(), err)
|
"Error waiting for droplet (%s) to become powered off: %s", d.Id(), err)
|
||||||
|
@ -227,7 +224,6 @@ func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{})
|
||||||
|
|
||||||
// Resize the droplet
|
// Resize the droplet
|
||||||
err = client.Resize(d.Id(), newSize.(string))
|
err = client.Resize(d.Id(), newSize.(string))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newErr := powerOnAndWait(d, meta)
|
newErr := powerOnAndWait(d, meta)
|
||||||
if newErr != nil {
|
if newErr != nil {
|
||||||
|
@ -261,7 +257,6 @@ func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{})
|
||||||
|
|
||||||
// Wait for power off
|
// Wait for power off
|
||||||
_, err = WaitForDropletAttribute(d, "active", []string{"off"}, "status", meta)
|
_, err = WaitForDropletAttribute(d, "active", []string{"off"}, "status", meta)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -375,7 +370,6 @@ func newDropletStateRefreshFunc(
|
||||||
client := meta.(*digitalocean.Client)
|
client := meta.(*digitalocean.Client)
|
||||||
return func() (interface{}, string, error) {
|
return func() (interface{}, string, error) {
|
||||||
err := resourceDigitalOceanDropletRead(d, meta)
|
err := resourceDigitalOceanDropletRead(d, meta)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
|
@ -392,7 +386,6 @@ func newDropletStateRefreshFunc(
|
||||||
if attr, ok := d.GetOk(attribute); ok {
|
if attr, ok := d.GetOk(attribute); ok {
|
||||||
// Retrieve the droplet properties
|
// Retrieve the droplet properties
|
||||||
droplet, err := client.RetrieveDroplet(d.Id())
|
droplet, err := client.RetrieveDroplet(d.Id())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", fmt.Errorf("Error retrieving droplet: %s", err)
|
return nil, "", fmt.Errorf("Error retrieving droplet: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -408,14 +401,12 @@ func newDropletStateRefreshFunc(
|
||||||
func powerOnAndWait(d *schema.ResourceData, meta interface{}) error {
|
func powerOnAndWait(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*digitalocean.Client)
|
client := meta.(*digitalocean.Client)
|
||||||
err := client.PowerOn(d.Id())
|
err := client.PowerOn(d.Id())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for power on
|
// Wait for power on
|
||||||
_, err = WaitForDropletAttribute(d, "active", []string{"off"}, "status", client)
|
_, err = WaitForDropletAttribute(d, "active", []string{"off"}, "status", client)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue