aboutsummaryrefslogtreecommitdiffhomepage
path: root/mailgun
diff options
context:
space:
mode:
authoralexandreFre <51956137+alexandreFre@users.noreply.github.com>2019-08-05 12:08:03 +0200
committerGitHub <noreply@github.com>2019-08-05 12:08:03 +0200
commit6775dea7c26c00e11e2cabeb06bce07fd63ddc61 (patch)
treec39ed3e34defe7dd57c7716abd9642f759bfbb26 /mailgun
parent9d6df78b1174819ed7660295aa42d7fa9c3e647c (diff)
parent14eb80abd418ef94f851caaf8dae1654e0296475 (diff)
downloadterraform-provider-mailgun-6775dea7c26c00e11e2cabeb06bce07fd63ddc61.tar.gz
terraform-provider-mailgun-6775dea7c26c00e11e2cabeb06bce07fd63ddc61.tar.zst
terraform-provider-mailgun-6775dea7c26c00e11e2cabeb06bce07fd63ddc61.zip
Merge pull request #17 from alexandreFre/fix_test
fix credentials and date
Diffstat (limited to 'mailgun')
-rw-r--r--mailgun/resource_mailgun_domain.go22
-rw-r--r--mailgun/resource_mailgun_route.go2
2 files changed, 15 insertions, 9 deletions
diff --git a/mailgun/resource_mailgun_domain.go b/mailgun/resource_mailgun_domain.go
index c195cf0..48f3a1a 100644
--- a/mailgun/resource_mailgun_domain.go
+++ b/mailgun/resource_mailgun_domain.go
@@ -99,7 +99,7 @@ func resourceMailgunDomain() *schema.Resource {
99 }, 99 },
100 "password": &schema.Schema{ 100 "password": &schema.Schema{
101 Type: schema.TypeString, 101 Type: schema.TypeString,
102 Required: true, 102 Optional: true,
103 }, 103 },
104 }, 104 },
105 }, 105 },
@@ -314,7 +314,7 @@ func UpdateDomain(d *schema.ResourceData, meta interface{}) error {
314 newCredential := j.(map[string]interface{}) 314 newCredential := j.(map[string]interface{})
315 if oldCredential["login"] == newCredential["login"] { 315 if oldCredential["login"] == newCredential["login"] {
316 found = true 316 found = true
317 if oldCredential["password"] != newCredential["password"] { 317 if oldCredential["password"] != newCredential["password"] && newCredential["password"] != "" {
318 err := mg.ChangeCredentialPassword(ctx, oldCredential["login"].(string), newCredential["password"].(string)) 318 err := mg.ChangeCredentialPassword(ctx, oldCredential["login"].(string), newCredential["password"].(string))
319 if err != nil { 319 if err != nil {
320 return fmt.Errorf("Error updating mailgun credential password: %s", err.Error()) 320 return fmt.Errorf("Error updating mailgun credential password: %s", err.Error())
@@ -376,11 +376,10 @@ func ReadDomain(d *schema.ResourceData, meta interface{}) error {
376 if err != nil { 376 if err != nil {
377 return fmt.Errorf("Error Getting mailgun domain Details for %s: Error: %s", d.Id(), err) 377 return fmt.Errorf("Error Getting mailgun domain Details for %s: Error: %s", d.Id(), err)
378 } 378 }
379 379 d.Set("created_at", domainResponse.Domain.CreatedAt.String())
380 d.Set("created_at", domainResponse.Domain.CreatedAt) 380 d.Set("smtp_login", domainResponse.Domain.SMTPLogin)
381 d.Set("smtd_login", domainResponse.Domain.SMTPLogin)
382 d.Set("name", domainResponse.Domain.Name) 381 d.Set("name", domainResponse.Domain.Name)
383 d.Set("smtd_password", domainResponse.Domain.SMTPPassword) 382 d.Set("smtp_password", domainResponse.Domain.SMTPPassword)
384 d.Set("wildcard", domainResponse.Domain.Wildcard) 383 d.Set("wildcard", domainResponse.Domain.Wildcard)
385 d.Set("spam_action", domainResponse.Domain.SpamAction) 384 d.Set("spam_action", domainResponse.Domain.SpamAction)
386 d.Set("state", domainResponse.Domain.State) 385 d.Set("state", domainResponse.Domain.State)
@@ -444,12 +443,19 @@ func ReadDomain(d *schema.ResourceData, meta interface{}) error {
444 } 443 }
445 444
446 credentials := make([]map[string]interface{}, len(credentialsResponse)) 445 credentials := make([]map[string]interface{}, len(credentialsResponse))
446 credentialsConf := d.Get("credentials").([]interface{})
447 for i, r := range credentialsResponse { 447 for i, r := range credentialsResponse {
448 credentials[i] = make(map[string]interface{}) 448 credentials[i] = make(map[string]interface{})
449 credentials[i]["created_at"] = r.CreatedAt 449 credentials[i]["created_at"] = r.CreatedAt.String()
450 credentials[i]["login"] = r.Login 450 credentials[i]["login"] = r.Login
451 credentials[i]["password"] = r.Password 451 for _, c:= range credentialsConf {
452 conf:=c.(map[string]interface{})
453 if conf["login"] == credentials[i]["login"] {
454 credentials[i]["password"] = conf["password"]
455 }
456 }
452 } 457 }
458
453 d.Set("credentials", credentials) 459 d.Set("credentials", credentials)
454 460
455 d.SetId(domainName) 461 d.SetId(domainName)
diff --git a/mailgun/resource_mailgun_route.go b/mailgun/resource_mailgun_route.go
index cf8290f..308da44 100644
--- a/mailgun/resource_mailgun_route.go
+++ b/mailgun/resource_mailgun_route.go
@@ -123,7 +123,7 @@ func ReadRoute(d *schema.ResourceData, meta interface{}) error {
123 d.Set("description", route.Description) 123 d.Set("description", route.Description)
124 d.Set("expression", route.Expression) 124 d.Set("expression", route.Expression)
125 d.Set("actions", route.Actions) 125 d.Set("actions", route.Actions)
126 d.Set("created_at", route.CreatedAt) 126 d.Set("created_at", route.CreatedAt.String())
127 d.Set("route_id", route.Id) 127 d.Set("route_id", route.Id)
128 128
129 d.SetId(route.Id) 129 d.SetId(route.Id)