Skip to content

Commit 86af71a

Browse files
author
Paul Hinze
committed
providers/mailgun: fix sending/receiving records
The Mailgun provider was relying on an old behavior of `ResourceData.Set` that would allow nested access to maps. We now just build up our own maps like sane people.
1 parent 17680bb commit 86af71a

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

builtin/providers/mailgun/resource_mailgun_domain.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,25 @@ func resourceMailginDomainRetrieve(id string, client *mailgun.Client, d *schema.
171171
d.Set("wildcard", resp.Domain.Wildcard)
172172
d.Set("spam_action", resp.Domain.SpamAction)
173173

174-
d.Set("receiving_records", make([]interface{}, len(resp.ReceivingRecords)))
174+
receivingRecords := make([]map[string]interface{}, len(resp.ReceivingRecords))
175175
for i, r := range resp.ReceivingRecords {
176-
prefix := fmt.Sprintf("receiving_records.%d", i)
177-
d.Set(prefix+".priority", r.Priority)
178-
d.Set(prefix+".valid", r.Valid)
179-
d.Set(prefix+".value", r.Value)
180-
d.Set(prefix+".record_type", r.RecordType)
176+
receivingRecords[i] = make(map[string]interface{})
177+
receivingRecords[i]["priority"] = r.Priority
178+
receivingRecords[i]["valid"] = r.Valid
179+
receivingRecords[i]["value"] = r.Value
180+
receivingRecords[i]["record_type"] = r.RecordType
181181
}
182+
d.Set("receiving_records", receivingRecords)
182183

183-
d.Set("sending_records", make([]interface{}, len(resp.SendingRecords)))
184+
sendingRecords := make([]map[string]interface{}, len(resp.SendingRecords))
184185
for i, r := range resp.SendingRecords {
185-
prefix := fmt.Sprintf("sending_records.%d", i)
186-
d.Set(prefix+".name", r.Name)
187-
d.Set(prefix+".valid", r.Valid)
188-
d.Set(prefix+".value", r.Value)
189-
d.Set(prefix+".record_type", r.RecordType)
186+
sendingRecords[i] = make(map[string]interface{})
187+
sendingRecords[i]["name"] = r.Name
188+
sendingRecords[i]["valid"] = r.Valid
189+
sendingRecords[i]["value"] = r.Value
190+
sendingRecords[i]["record_type"] = r.RecordType
190191
}
192+
d.Set("sending_records", sendingRecords)
191193

192194
return &resp, nil
193195
}

0 commit comments

Comments
 (0)