]> git.immae.eu Git - github/fretlink/terraform-provider-mailgun.git/commitdiff
change import function to avoid setting default in read 14/head
authorAlexandre Garand <alexandre.garand@fretlink.com>
Mon, 8 Jul 2019 15:57:18 +0000 (17:57 +0200)
committerAlexandre Garand <alexandre.garand@fretlink.com>
Mon, 8 Jul 2019 15:57:18 +0000 (17:57 +0200)
mailgun/resource_mailgun_domain.go

index 8ba0704dc7745082fe51ab834dc856cb3cf53c2f..86531c62aec01cefcdbb59a767f3a93beaada9e9 100644 (file)
@@ -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
+}