providers/digitalocean: handle when resource deleted manually [GH-279]

This commit is contained in:
Mitchell Hashimoto 2014-09-09 13:36:47 -07:00
parent 79faad89df
commit ff7f327793
2 changed files with 14 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package digitalocean
import (
"fmt"
"log"
"strings"
"github.com/hashicorp/terraform/helper/config"
"github.com/hashicorp/terraform/helper/diff"
@ -63,8 +64,13 @@ func resource_digitalocean_domain_refresh(
client := p.client
domain, err := client.RetrieveDomain(s.ID)
if err != nil {
// If the domain is somehow already destroyed, mark as
// succesfully gone
if strings.Contains(err.Error(), "404 Not Found") {
return nil, nil
}
return s, fmt.Errorf("Error retrieving domain: %s", err)
}

View File

@ -135,6 +135,13 @@ func resourceRecordRead(d *schema.ResourceData, meta interface{}) error {
rec, err := client.RetrieveRecord(d.Get("domain").(string), d.Id())
if err != nil {
// If the record is somehow already destroyed, mark as
// succesfully gone
if strings.Contains(err.Error(), "404 Not Found") {
d.SetId("")
return nil
}
return err
}