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

upgrade to auth0.v2 and fix email templates #144

Merged
merged 2 commits into from
Dec 11, 2019
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
11 changes: 7 additions & 4 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."
Expand Down
2 changes: 1 addition & 1 deletion auth0/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions auth0/resource_auth0_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions auth0/resource_auth0_client_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions auth0/resource_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 5 additions & 14 deletions auth0/resource_auth0_custom_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ 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 {
return &schema.Resource{

Create: createCustomDomain,
Read: readCustomDomain,
Update: updateCustomDomain,
Delete: deleteCustomDomain,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
Expand All @@ -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",
Expand All @@ -42,6 +43,7 @@ func newCustomDomain() *schema.Resource {
"verification_method": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"txt"}, true),
},
"verification": {
Expand Down Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions auth0/resource_auth0_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 7 additions & 4 deletions auth0/resource_auth0_email_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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"),
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions auth0/resource_auth0_resource_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions auth0/resource_auth0_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions auth0/resource_auth0_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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-]$")
Expand Down
4 changes: 2 additions & 2 deletions auth0/resource_auth0_rule_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion auth0/resource_auth0_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions auth0/resource_auth0_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion auth0/resource_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/email_template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down