From b8802d62b2dcaad11d846bde7306b74f49263e5e Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Mon, 8 Jul 2019 17:57:18 +0200 Subject: change import function to avoid setting default in read --- mailgun/resource_mailgun_domain.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mailgun/resource_mailgun_domain.go b/mailgun/resource_mailgun_domain.go index 8ba0704..86531c6 100644 --- a/mailgun/resource_mailgun_domain.go +++ b/mailgun/resource_mailgun_domain.go @@ -16,7 +16,7 @@ func resourceMailgunDomain() *schema.Resource { Delete: DeleteDomain, Read: ReadDomain, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + State: ImportStatePassthroughDomain, }, Schema: map[string]*schema.Schema{ @@ -375,13 +375,6 @@ func ReadDomain(d *schema.ResourceData, meta interface{}) error { if err != nil { return fmt.Errorf("Error Getting mailgun domain Details for %s: Error: %s", d.Id(), err) } - if _, ok := d.GetOk("dkim_key_size"); !ok { - d.Set("dkim_key_size", 1024) - } - - if _, ok := d.GetOk("force_dkim_authority"); !ok { - d.Set("force_dkim_authority", false) - } d.Set("created_at", domainResponse.Domain.CreatedAt) d.Set("smtd_login", domainResponse.Domain.SMTPLogin) @@ -489,3 +482,14 @@ func ListCredentials(domain, apiKey string) ([]mailgun.Credential, error) { } return result, nil } + +func ImportStatePassthroughDomain(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + if _, ok := d.GetOk("dkim_key_size"); !ok { + d.Set("dkim_key_size", 1024) + } + + if _, ok := d.GetOk("force_dkim_authority"); !ok { + d.Set("force_dkim_authority", false) + } + return []*schema.ResourceData{d}, nil +} -- cgit v1.2.3