Skip to content

Commit

Permalink
Add comment for create func.
Browse files Browse the repository at this point in the history
Add a comment explaining why we have such wonky update logic in the
create func for NS record sets.
  • Loading branch information
paddycarver committed Nov 8, 2017
1 parent 0e2fa2e commit 4a342ca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions google/resource_dns_record_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error
},
}

// we need to replace NS record sets in the same call. That means
// we need to list all the current NS record sets attached to the
// zone and add them to the change as deletions. We can't just add
// new NS record sets, or we'll get an error about the NS record set
// already existing; see terraform-providers/terraform-provider-google#95.
// We also can't just remove the NS recordsets on creation, as at
// least one is required. So the solution is to "update in place" by
// putting the addition and the removal in the same API call.
if d.Get("type").(string) == "NS" {
log.Printf("[DEBUG] DNS record list request for %q", zone)
res, err := config.clientDns.ResourceRecordSets.List(project, zone).Do()
Expand Down

0 comments on commit 4a342ca

Please sign in to comment.