aboutsummaryrefslogtreecommitdiffhomepage
path: root/mailgun/resource_mailgun_domain.go
diff options
context:
space:
mode:
authoralexandreFre <51956137+alexandreFre@users.noreply.github.com>2019-07-09 10:32:31 +0200
committerGitHub <noreply@github.com>2019-07-09 10:32:31 +0200
commitdbbb014f494c502d8ac26437acd02412ee275b5a (patch)
tree57d42534000bfd9b7f1f73a3af62343d4a3a94a3 /mailgun/resource_mailgun_domain.go
parent1b47892a9bef231b3e54c40345ae23a4b3b701e0 (diff)
parentb8802d62b2dcaad11d846bde7306b74f49263e5e (diff)
downloadterraform-provider-mailgun-dbbb014f494c502d8ac26437acd02412ee275b5a.tar.gz
terraform-provider-mailgun-dbbb014f494c502d8ac26437acd02412ee275b5a.tar.zst
terraform-provider-mailgun-dbbb014f494c502d8ac26437acd02412ee275b5a.zip
Merge pull request #14 from alexandreFre/add_import_test
Add test for importation
Diffstat (limited to 'mailgun/resource_mailgun_domain.go')
-rw-r--r--mailgun/resource_mailgun_domain.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/mailgun/resource_mailgun_domain.go b/mailgun/resource_mailgun_domain.go
index 1fcba83..86531c6 100644
--- a/mailgun/resource_mailgun_domain.go
+++ b/mailgun/resource_mailgun_domain.go
@@ -16,7 +16,7 @@ func resourceMailgunDomain() *schema.Resource {
16 Delete: DeleteDomain, 16 Delete: DeleteDomain,
17 Read: ReadDomain, 17 Read: ReadDomain,
18 Importer: &schema.ResourceImporter{ 18 Importer: &schema.ResourceImporter{
19 State: schema.ImportStatePassthrough, 19 State: ImportStatePassthroughDomain,
20 }, 20 },
21 21
22 Schema: map[string]*schema.Schema{ 22 Schema: map[string]*schema.Schema{
@@ -368,7 +368,7 @@ func ReadDomain(d *schema.ResourceData, meta interface{}) error {
368 mg := meta.(*mailgun.MailgunImpl) 368 mg := meta.(*mailgun.MailgunImpl)
369 ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) 369 ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
370 defer cancel() 370 defer cancel()
371 domainName := d.Get("name").(string) 371 domainName := d.Id()
372 mg = mailgun.NewMailgun(domainName, mg.APIKey()) 372 mg = mailgun.NewMailgun(domainName, mg.APIKey())
373 373
374 domainResponse, err := mg.GetDomain(ctx, domainName) 374 domainResponse, err := mg.GetDomain(ctx, domainName)
@@ -482,3 +482,14 @@ func ListCredentials(domain, apiKey string) ([]mailgun.Credential, error) {
482 } 482 }
483 return result, nil 483 return result, nil
484} 484}
485
486func ImportStatePassthroughDomain(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
487 if _, ok := d.GetOk("dkim_key_size"); !ok {
488 d.Set("dkim_key_size", 1024)
489 }
490
491 if _, ok := d.GetOk("force_dkim_authority"); !ok {
492 d.Set("force_dkim_authority", false)
493 }
494 return []*schema.ResourceData{d}, nil
495}