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 a9c8ccb29b
commit 228fd035ba
3 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,8 @@ BUG FIXES:
* core: "~" is expanded in `-var-file` flags. [GH-273]
* core: Errors with tfvars are shown in console. [GH-269]
* providers/aws: Refreshing EIP from pre-0.2 state file won't error. [GH-258]
* providers/digitalocean: Handle situations when resource was destroyed
manually. [GH-279]
* providers/google: Attaching a disk source (not an image) works
properly. [GH-254]

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
}