Skip to content

Commit

Permalink
Merge pull request #2777 from dwradcliffe/dnsimple_force_new
Browse files Browse the repository at this point in the history
provider/dnsimple: domain and type should force new records
  • Loading branch information
phinze committed Jul 29, 2015
2 parents 3080c82 + f1cc9fa commit efaf639
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions builtin/providers/dnsimple/resource_dnsimple_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func resourceDNSimpleRecord() *schema.Resource {
"domain": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"domain_id": &schema.Schema{
Expand All @@ -39,6 +40,7 @@ func resourceDNSimpleRecord() *schema.Resource {
"type": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"value": &schema.Schema{
Expand Down Expand Up @@ -74,12 +76,12 @@ func resourceDNSimpleRecordCreate(d *schema.ResourceData, meta interface{}) erro
newRecord.Ttl = ttl.(string)
}

log.Printf("[DEBUG] DNS Simple Record create configuration: %#v", newRecord)
log.Printf("[DEBUG] DNSimple Record create configuration: %#v", newRecord)

recId, err := client.CreateRecord(d.Get("domain").(string), newRecord)

if err != nil {
return fmt.Errorf("Failed to create DNS Simple Record: %s", err)
return fmt.Errorf("Failed to create DNSimple Record: %s", err)
}

d.SetId(recId)
Expand All @@ -93,7 +95,7 @@ func resourceDNSimpleRecordRead(d *schema.ResourceData, meta interface{}) error

rec, err := client.RetrieveRecord(d.Get("domain").(string), d.Id())
if err != nil {
return fmt.Errorf("Couldn't find DNS Simple Record: %s", err)
return fmt.Errorf("Couldn't find DNSimple Record: %s", err)
}

d.Set("domain_id", rec.StringDomainId())
Expand Down Expand Up @@ -133,11 +135,11 @@ func resourceDNSimpleRecordUpdate(d *schema.ResourceData, meta interface{}) erro
updateRecord.Ttl = attr.(string)
}

log.Printf("[DEBUG] DNS Simple Record update configuration: %#v", updateRecord)
log.Printf("[DEBUG] DNSimple Record update configuration: %#v", updateRecord)

_, err := client.UpdateRecord(d.Get("domain").(string), d.Id(), updateRecord)
if err != nil {
return fmt.Errorf("Failed to update DNS Simple Record: %s", err)
return fmt.Errorf("Failed to update DNSimple Record: %s", err)
}

return resourceDNSimpleRecordRead(d, meta)
Expand All @@ -146,12 +148,12 @@ func resourceDNSimpleRecordUpdate(d *schema.ResourceData, meta interface{}) erro
func resourceDNSimpleRecordDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*dnsimple.Client)

log.Printf("[INFO] Deleting DNS Simple Record: %s, %s", d.Get("domain").(string), d.Id())
log.Printf("[INFO] Deleting DNSimple Record: %s, %s", d.Get("domain").(string), d.Id())

err := client.DestroyRecord(d.Get("domain").(string), d.Id())

if err != nil {
return fmt.Errorf("Error deleting DNS Simple Record: %s", err)
return fmt.Errorf("Error deleting DNSimple Record: %s", err)
}

return nil
Expand Down

0 comments on commit efaf639

Please sign in to comment.