From 0e2abba46f01b5f15763e2ef5edafab1eb13a35f Mon Sep 17 00:00:00 2001 From: Alex Kalyvitis Date: Fri, 1 Jun 2018 12:19:08 +0200 Subject: [PATCH] read remote values into custom domain (#15) --- auth0/resource_auth0_custom_domain.go | 22 ++++++++++------------ auth0/resource_auth0_custom_domain_test.go | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/auth0/resource_auth0_custom_domain.go b/auth0/resource_auth0_custom_domain.go index 1993a521..eeeea21e 100644 --- a/auth0/resource_auth0_custom_domain.go +++ b/auth0/resource_auth0_custom_domain.go @@ -68,13 +68,7 @@ func createCustomDomain(d *schema.ResourceData, m interface{}) error { return err } d.SetId(c.ID) - verification := []map[string]interface{}{ - {"methods": c.Verification.Methods}, - } - if err := d.Set("verification", verification); err != nil { - return err - } - return nil + return readCustomDomain(d, m) } func readCustomDomain(d *schema.ResourceData, m interface{}) error { @@ -84,6 +78,13 @@ func readCustomDomain(d *schema.ResourceData, m interface{}) error { return err } d.SetId(c.ID) + d.Set("domain", c.Domain) + d.Set("type", c.Type) + d.Set("primary", c.Primary) + d.Set("status", c.Status) + d.Set("verification", []map[string]interface{}{ + {"methods": c.Verification.Methods}, + }) return nil } @@ -95,7 +96,7 @@ func updateCustomDomain(d *schema.ResourceData, m interface{}) error { if err != nil { return err } - return nil + return readCustomDomain(d, m) } func deleteCustomDomain(d *schema.ResourceData, m interface{}) error { @@ -104,12 +105,9 @@ func deleteCustomDomain(d *schema.ResourceData, m interface{}) error { } func buildCustomDomain(d *schema.ResourceData) *management.CustomDomain { - - c := &management.CustomDomain{ + return &management.CustomDomain{ Domain: d.Get("domain").(string), Type: d.Get("type").(string), VerificationMethod: d.Get("verification_method").(string), } - - return c } diff --git a/auth0/resource_auth0_custom_domain_test.go b/auth0/resource_auth0_custom_domain_test.go index 7d265f3e..3baf6f75 100644 --- a/auth0/resource_auth0_custom_domain_test.go +++ b/auth0/resource_auth0_custom_domain_test.go @@ -19,7 +19,7 @@ func TestAccCustomDomain(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "domain", "auth.example.com"), resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "type", "auth0_managed_certs"), - resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "verification_method", "txt"), + resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "status", "pending_verification"), ), }, },