diff --git a/GNUmakefile b/GNUmakefile index 85006e2e..5d08afd0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -8,15 +8,18 @@ WEBSITE_REPO = github.com/hashicorp/terraform-website default: build build: fmtcheck - go install + @go install + +install: build + @cp $(GOPATH)/bin/terraform-provider-auth0 ~/.terraform.d/plugins test: fmtcheck - go test -i $(PKGS) || exit 1 - echo $(PKGS) | \ + @go test -i $(PKGS) || exit 1 + @echo $(PKGS) | \ xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 -run ^$(TESTS)$ testacc: fmtcheck - TF_ACC=1 go test $(PKGS) -v $(TESTARGS) -timeout 120m -coverprofile=$(COVERS) -run ^$(TESTS)$ + @TF_ACC=1 go test $(PKGS) -v $(TESTARGS) -timeout 120m -coverprofile=$(COVERS) -run ^$(TESTS)$ vet: @echo "go vet ." diff --git a/auth0/provider.go b/auth0/provider.go index c0f2a055..666ee82f 100644 --- a/auth0/provider.go +++ b/auth0/provider.go @@ -4,7 +4,7 @@ import ( "os" "github.com/hashicorp/terraform/helper/schema" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2/management" ) func Provider() *schema.Provider { diff --git a/auth0/resource_auth0_client.go b/auth0/resource_auth0_client.go index ed070fa5..f325a55f 100644 --- a/auth0/resource_auth0_client.go +++ b/auth0/resource_auth0_client.go @@ -5,8 +5,8 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newClient() *schema.Resource { diff --git a/auth0/resource_auth0_client_grant.go b/auth0/resource_auth0_client_grant.go index 68b4c4ca..c45a47c7 100644 --- a/auth0/resource_auth0_client_grant.go +++ b/auth0/resource_auth0_client_grant.go @@ -2,8 +2,8 @@ package auth0 import ( "github.com/hashicorp/terraform/helper/schema" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newClientGrant() *schema.Resource { diff --git a/auth0/resource_auth0_connection.go b/auth0/resource_auth0_connection.go index aafa7a24..3754db25 100644 --- a/auth0/resource_auth0_connection.go +++ b/auth0/resource_auth0_connection.go @@ -5,8 +5,8 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newConnection() *schema.Resource { diff --git a/auth0/resource_auth0_custom_domain.go b/auth0/resource_auth0_custom_domain.go index e2e8f8fb..328866e0 100644 --- a/auth0/resource_auth0_custom_domain.go +++ b/auth0/resource_auth0_custom_domain.go @@ -3,8 +3,8 @@ package auth0 import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newCustomDomain() *schema.Resource { @@ -12,7 +12,6 @@ func newCustomDomain() *schema.Resource { Create: createCustomDomain, Read: readCustomDomain, - Update: updateCustomDomain, Delete: deleteCustomDomain, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, @@ -22,10 +21,12 @@ func newCustomDomain() *schema.Resource { "domain": { Type: schema.TypeString, Required: true, + ForceNew: true, }, "type": { Type: schema.TypeString, Required: true, + ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ "auth0_managed_certs", "self_managed_certs", @@ -42,6 +43,7 @@ func newCustomDomain() *schema.Resource { "verification_method": { Type: schema.TypeString, Required: true, + ForceNew: true, ValidateFunc: validation.StringInSlice([]string{"txt"}, true), }, "verification": { @@ -93,17 +95,6 @@ func readCustomDomain(d *schema.ResourceData, m interface{}) error { return nil } -func updateCustomDomain(d *schema.ResourceData, m interface{}) error { - c := buildCustomDomain(d) - c.Verification = nil - api := m.(*management.Management) - err := api.CustomDomain.Update(d.Id(), c) - if err != nil { - return err - } - return readCustomDomain(d, m) -} - func deleteCustomDomain(d *schema.ResourceData, m interface{}) error { api := m.(*management.Management) return api.CustomDomain.Delete(d.Id()) diff --git a/auth0/resource_auth0_email.go b/auth0/resource_auth0_email.go index 30eca7dd..a898f3bf 100644 --- a/auth0/resource_auth0_email.go +++ b/auth0/resource_auth0_email.go @@ -2,8 +2,8 @@ package auth0 import ( "github.com/hashicorp/terraform/helper/schema" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newEmail() *schema.Resource { diff --git a/auth0/resource_auth0_email_template.go b/auth0/resource_auth0_email_template.go index 87aed84e..7aed8261 100644 --- a/auth0/resource_auth0_email_template.go +++ b/auth0/resource_auth0_email_template.go @@ -3,8 +3,9 @@ package auth0 import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" + "log" ) func newEmailTemplate() *schema.Resource { @@ -115,7 +116,7 @@ func readEmailTemplate(d *schema.ResourceData, m interface{}) error { func updateEmailTemplate(d *schema.ResourceData, m interface{}) error { e := buildEmailTemplate(d) api := m.(*management.Management) - err := api.EmailTemplate.Replace(auth0.StringValue(e.Template), e) + err := api.EmailTemplate.Update(d.Id(), e) if err != nil { return err } @@ -132,7 +133,7 @@ func deleteEmailTemplate(d *schema.ResourceData, m interface{}) error { } func buildEmailTemplate(d *schema.ResourceData) *management.EmailTemplate { - return &management.EmailTemplate{ + t := &management.EmailTemplate{ Template: String(d, "template"), Body: String(d, "body"), From: String(d, "from"), @@ -142,4 +143,6 @@ func buildEmailTemplate(d *schema.ResourceData) *management.EmailTemplate { URLLifetimeInSecoonds: Int(d, "url_lifetime_in_seconds"), Enabled: Bool(d, "enabled"), } + log.Printf("[DEBUG] Template: %s", t) + return t } diff --git a/auth0/resource_auth0_resource_server.go b/auth0/resource_auth0_resource_server.go index 806d9d0e..745c198c 100644 --- a/auth0/resource_auth0_resource_server.go +++ b/auth0/resource_auth0_resource_server.go @@ -2,8 +2,8 @@ package auth0 import ( "github.com/hashicorp/terraform/helper/schema" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newResourceServer() *schema.Resource { diff --git a/auth0/resource_auth0_role.go b/auth0/resource_auth0_role.go index 79fb75c8..e70cecad 100644 --- a/auth0/resource_auth0_role.go +++ b/auth0/resource_auth0_role.go @@ -2,8 +2,8 @@ package auth0 import ( "github.com/hashicorp/terraform/helper/schema" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newRole() *schema.Resource { @@ -88,7 +88,7 @@ func createRole(d *schema.ResourceData, m interface{}) error { if d.HasChange("permissions") { permissions := buildPermissions(d) if len(permissions) > 0 { - err := api.Role.AssignPermissions(*c.ID, permissions...) + err := api.Role.AssociatePermissions(*c.ID, permissions...) if err != nil { return err } diff --git a/auth0/resource_auth0_rule.go b/auth0/resource_auth0_rule.go index 4b890293..a9b09ed2 100644 --- a/auth0/resource_auth0_rule.go +++ b/auth0/resource_auth0_rule.go @@ -5,8 +5,8 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) var ruleNameRegexp = regexp.MustCompile("^[^\\s-][\\w -]+[^\\s-]$") diff --git a/auth0/resource_auth0_rule_config.go b/auth0/resource_auth0_rule_config.go index 98086c6f..8954e28b 100644 --- a/auth0/resource_auth0_rule_config.go +++ b/auth0/resource_auth0_rule_config.go @@ -2,8 +2,8 @@ package auth0 import ( "github.com/hashicorp/terraform/helper/schema" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newRuleConfig() *schema.Resource { diff --git a/auth0/resource_auth0_tenant.go b/auth0/resource_auth0_tenant.go index 543afc8b..df279e3b 100644 --- a/auth0/resource_auth0_tenant.go +++ b/auth0/resource_auth0_tenant.go @@ -3,7 +3,7 @@ package auth0 import ( "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2/management" ) func newTenant() *schema.Resource { diff --git a/auth0/resource_auth0_user.go b/auth0/resource_auth0_user.go index e1a1c647..4bc00f89 100644 --- a/auth0/resource_auth0_user.go +++ b/auth0/resource_auth0_user.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/structure" "github.com/hashicorp/terraform/helper/validation" - "gopkg.in/auth0.v1" - "gopkg.in/auth0.v1/management" + "gopkg.in/auth0.v2" + "gopkg.in/auth0.v2/management" ) func newUser() *schema.Resource { diff --git a/auth0/resource_data.go b/auth0/resource_data.go index d821b331..b9550448 100644 --- a/auth0/resource_data.go +++ b/auth0/resource_data.go @@ -4,7 +4,7 @@ import ( "reflect" "github.com/hashicorp/terraform/helper/schema" - "gopkg.in/auth0.v1" + "gopkg.in/auth0.v2" ) // Data generalises schema.ResourceData so that we can reuse the accessor diff --git a/example/email_template/main.tf b/example/email_template/main.tf index 6fc853f6..f1bb9292 100644 --- a/example/email_template/main.tf +++ b/example/email_template/main.tf @@ -21,5 +21,5 @@ resource "auth0_email_template" "my_email_template" { url_lifetime_in_seconds = 3600 enabled = true - depends_on = ["auth0_email.my_email_provider"] + depends_on = [ auth0_email.my_email_provider ] } diff --git a/go.mod b/go.mod index 9ce1d313..5b78ce30 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,5 @@ go 1.12 require ( github.com/hashicorp/terraform v0.12.7 - gopkg.in/auth0.v1 v1.2.7 + gopkg.in/auth0.v2 v2.1.0 ) diff --git a/go.sum b/go.sum index 99999a76..a78567e3 100644 --- a/go.sum +++ b/go.sum @@ -525,6 +525,10 @@ gopkg.in/auth0.v1 v1.2.6 h1:5atuVrxOUOToefuI7DrCSGMgF8jR2fMWEwFN2UqrLrk= gopkg.in/auth0.v1 v1.2.6/go.mod h1:1FRtMXwYDgygZcO7Of7kj/I4mf9UjHGhMHUOqNT0d0M= gopkg.in/auth0.v1 v1.2.7 h1:9UCE5rKFL60rqQENmmJaGdNu7/aby8r8wVcJ83Vj5oU= gopkg.in/auth0.v1 v1.2.7/go.mod h1:1FRtMXwYDgygZcO7Of7kj/I4mf9UjHGhMHUOqNT0d0M= +gopkg.in/auth0.v1 v1.3.0 h1:aTOwTaF6b05DqqvVKJa0c7BrxdtvT29Yg0WhR80cLoU= +gopkg.in/auth0.v1 v1.3.0/go.mod h1:1FRtMXwYDgygZcO7Of7kj/I4mf9UjHGhMHUOqNT0d0M= +gopkg.in/auth0.v2 v2.1.0 h1:oC5odKqifbe1tJXLIZiPKjk3hQVQCKV1dgkJS7dZO+U= +gopkg.in/auth0.v2 v2.1.0/go.mod h1:jxN9MOCqjQnRvVRbnB4U8fu1nuNHj4m4AnRJbiRh0RQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=