Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Custom Domain read remote values correctly #15

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions auth0/resource_auth0_custom_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand All @@ -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 {
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion auth0/resource_auth0_custom_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand Down