mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
providers/mailgun: return domain response instead of domain
see also 5b02e7e9ff
This commit is contained in:
parent
4fd3dff829
commit
02c93f0aea
@ -108,18 +108,18 @@ func resourceMailgunDomainRead(d *schema.ResourceData, meta interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func resource_mailgin_domain_retrieve(id string, client *mailgun.Client, d *schema.ResourceData) (*mailgun.Domain, error) {
|
||||
domain, err := client.RetrieveDomain(id)
|
||||
func resource_mailgin_domain_retrieve(id string, client *mailgun.Client, d *schema.ResourceData) (*mailgun.DomainResponse, error) {
|
||||
resp, err := client.RetrieveDomain(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error retrieving domain: %s", err)
|
||||
}
|
||||
|
||||
d.Set("name", domain.Name)
|
||||
d.Set("smtp_password", domain.SmtpPassword)
|
||||
d.Set("smtp_login", domain.SmtpLogin)
|
||||
d.Set("wildcard", domain.Wildcard)
|
||||
d.Set("spam_action", domain.SpamAction)
|
||||
d.Set("name", resp.Domain.Name)
|
||||
d.Set("smtp_password", resp.Domain.SmtpPassword)
|
||||
d.Set("smtp_login", resp.Domain.SmtpLogin)
|
||||
d.Set("wildcard", resp.Domain.Wildcard)
|
||||
d.Set("spam_action", resp.Domain.SpamAction)
|
||||
|
||||
return &domain, nil
|
||||
return &resp, nil
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAccMailgunDomain_Basic(t *testing.T) {
|
||||
var domain mailgun.Domain
|
||||
var resp mailgun.DomainResponse
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
@ -20,8 +20,8 @@ func TestAccMailgunDomain_Basic(t *testing.T) {
|
||||
resource.TestStep{
|
||||
Config: testAccCheckMailgunDomainConfig_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckMailgunDomainExists("mailgun_domain.foobar", &domain),
|
||||
testAccCheckMailgunDomainAttributes(&domain),
|
||||
testAccCheckMailgunDomainExists("mailgun_domain.foobar", &resp),
|
||||
testAccCheckMailgunDomainAttributes(&resp),
|
||||
resource.TestCheckResourceAttr(
|
||||
"mailgun_domain.foobar", "name", "terraform.example.com"),
|
||||
resource.TestCheckResourceAttr(
|
||||
@ -54,30 +54,30 @@ func testAccCheckMailgunDomainDestroy(s *terraform.State) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckMailgunDomainAttributes(Domain *mailgun.Domain) resource.TestCheckFunc {
|
||||
func testAccCheckMailgunDomainAttributes(DomainResp *mailgun.DomainResponse) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
|
||||
if Domain.Name != "terraform.example.com" {
|
||||
return fmt.Errorf("Bad name: %s", Domain.Name)
|
||||
if DomainResp.Domain.Name != "terraform.example.com" {
|
||||
return fmt.Errorf("Bad name: %s", DomainResp.Domain.Name)
|
||||
}
|
||||
|
||||
if Domain.SpamAction != "disabled" {
|
||||
return fmt.Errorf("Bad spam_action: %s", Domain.SpamAction)
|
||||
if DomainResp.Domain.SpamAction != "disabled" {
|
||||
return fmt.Errorf("Bad spam_action: %s", DomainResp.Domain.SpamAction)
|
||||
}
|
||||
|
||||
if Domain.Wildcard != true {
|
||||
return fmt.Errorf("Bad wildcard: %s", Domain.Wildcard)
|
||||
if DomainResp.Domain.Wildcard != true {
|
||||
return fmt.Errorf("Bad wildcard: %s", DomainResp.Domain.Wildcard)
|
||||
}
|
||||
|
||||
if Domain.SmtpPassword != "foobar" {
|
||||
return fmt.Errorf("Bad smtp_password: %s", Domain.SmtpPassword)
|
||||
if DomainResp.Domain.SmtpPassword != "foobar" {
|
||||
return fmt.Errorf("Bad smtp_password: %s", DomainResp.Domain.SmtpPassword)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func testAccCheckMailgunDomainExists(n string, Domain *mailgun.Domain) resource.TestCheckFunc {
|
||||
func testAccCheckMailgunDomainExists(n string, DomainResp *mailgun.DomainResponse) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.Resources[n]
|
||||
|
||||
@ -91,17 +91,17 @@ func testAccCheckMailgunDomainExists(n string, Domain *mailgun.Domain) resource.
|
||||
|
||||
client := testAccProvider.Meta().(*mailgun.Client)
|
||||
|
||||
foundDomain, err := client.RetrieveDomain(rs.ID)
|
||||
resp, err := client.RetrieveDomain(rs.ID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if foundDomain.Name != rs.ID {
|
||||
if resp.Domain.Name != rs.ID {
|
||||
return fmt.Errorf("Domain not found")
|
||||
}
|
||||
|
||||
*Domain = foundDomain
|
||||
*DomainResp = resp
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user