From 5c1feb2c5fe3962a8c5c1caffb81d6526eedf992 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Tue, 2 Jul 2019 11:39:41 +0200 Subject: [PATCH] fix issue read --- mailgun/resource_mailgun_domain.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mailgun/resource_mailgun_domain.go b/mailgun/resource_mailgun_domain.go index 028c99f..eaf00fa 100644 --- a/mailgun/resource_mailgun_domain.go +++ b/mailgun/resource_mailgun_domain.go @@ -360,8 +360,8 @@ func ReadDomain(d *schema.ResourceData, meta interface{}) error { mg := meta.(*mailgun.MailgunImpl) ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) defer cancel() - domainName := d.Get("name").(string) + mg = mailgun.NewMailgun(domainName, mg.APIKey()) domainResponse, err := mg.GetDomain(ctx, domainName) if err != nil { @@ -429,6 +429,10 @@ func ReadDomain(d *schema.ResourceData, meta interface{}) error { d.Set("ips", ips) credentialsResponse, err := ListCredentials(domainName, mg.APIKey()) + if err != nil { + return fmt.Errorf("Error Getting mailgun credentials for %s: Error: %s", d.Id(), err) + } + credentials := make([]map[string]interface{}, len(credentialsResponse)) for i, r := range credentialsResponse { credentials[i] = make(map[string]interface{}) -- 2.41.0