providers/mailgun: save domain records
This commit is contained in:
parent
02c93f0aea
commit
96c481578f
|
@ -46,6 +46,56 @@ func resourceMailgunDomain() *schema.Resource {
|
|||
ForceNew: true,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"receiving_records": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"priority": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"record_type": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"valid": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"value": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"sending_records": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"record_type": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"valid": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"value": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -121,5 +171,25 @@ func resource_mailgin_domain_retrieve(id string, client *mailgun.Client, d *sche
|
|||
d.Set("wildcard", resp.Domain.Wildcard)
|
||||
d.Set("spam_action", resp.Domain.SpamAction)
|
||||
|
||||
log.Println(resp.ReceivingRecords)
|
||||
|
||||
d.Set("receiving_records", make([]interface{}, len(resp.ReceivingRecords)))
|
||||
for i, r := range resp.ReceivingRecords {
|
||||
prefix := fmt.Sprintf("receiving_records.%d", i)
|
||||
d.Set(prefix+".priority", r.Priority)
|
||||
d.Set(prefix+".valid", r.Valid)
|
||||
d.Set(prefix+".value", r.Value)
|
||||
d.Set(prefix+".record_type", r.RecordType)
|
||||
}
|
||||
|
||||
d.Set("sending_records", make([]interface{}, len(resp.SendingRecords)))
|
||||
for i, r := range resp.SendingRecords {
|
||||
prefix := fmt.Sprintf("sending_records.%d", i)
|
||||
d.Set(prefix+".name", r.Name)
|
||||
d.Set(prefix+".valid", r.Valid)
|
||||
d.Set(prefix+".value", r.Value)
|
||||
d.Set(prefix+".record_type", r.RecordType)
|
||||
}
|
||||
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ func TestAccMailgunDomain_Basic(t *testing.T) {
|
|||
"mailgun_domain.foobar", "smtp_password", "foobar"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"mailgun_domain.foobar", "wildcard", "true"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"mailgun_domain.foobar", "receiving_records.0.priority", "10"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"mailgun_domain.foobar", "sending_records.0.name", "terraform.example.com"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -73,6 +77,14 @@ func testAccCheckMailgunDomainAttributes(DomainResp *mailgun.DomainResponse) res
|
|||
return fmt.Errorf("Bad smtp_password: %s", DomainResp.Domain.SmtpPassword)
|
||||
}
|
||||
|
||||
if DomainResp.ReceivingRecords[0].Priority == "" {
|
||||
return fmt.Errorf("Bad receiving_records: %s", DomainResp.ReceivingRecords)
|
||||
}
|
||||
|
||||
if DomainResp.SendingRecords[0].Name == "" {
|
||||
return fmt.Errorf("Bad sending_records: %s", DomainResp.SendingRecords)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue