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

Fix plan #1

Merged
merged 6 commits into from
Sep 9, 2021
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
41 changes: 26 additions & 15 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- binary: '{{ .ProjectName }}_v{{ .Version }}'
env:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- darwin
- linux
- windows
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
Expand All @@ -15,20 +28,18 @@ builds:
ignore:
- goos: darwin
goarch: '386'
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- -s -w -X version.ProviderVersion={{.Version}}
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
format: zip
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate it's not interactive.
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
Expand All @@ -37,7 +48,7 @@ signs:
- "--detach-sign"
- "${artifact}"
release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
skip: true
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build
on:
on:
push:
branches: ['*']
paths-ignore:
Expand Down Expand Up @@ -39,4 +39,4 @@ jobs:
uses: aktions/codeclimate-test-reporter@v1
with:
codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
command: after-build --prefix github.com/alexkappa/terraform-provider-auth0
command: after-build --prefix github.com/alekc/terraform-provider-auth0
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Release
on:
on:
push:
tags: ['*']

Expand All @@ -20,10 +20,13 @@ jobs:

- name: Determine version
run: echo VERSION=$(echo $GITHUB_REF | cut -d / -f 3 | sed -e "s/^v//") >> $GITHUB_ENV

- name: Import GPG key
id: gpg
uses: crazy-max/ghaction-import-gpg@v2
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}

Expand All @@ -37,4 +40,4 @@ jobs:
args: --config=.github/release.yml --skip-validate --release-notes release-notes.md
env:
GPG_FINGERPRINT: ${{ steps.gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Unreleased
## 0.21.1

FIXES:
* resource/auth0_branding: Fixed issue "template 404 not found" [#380](https://github.com/alexkappa/terraform-provider-auth0/issues/380)

ENHANCEMENTS:

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ successfully run.

## Releasing

The Auth0 provider folloows the [Versioning and Changelog](https://www.terraform.io/docs/extend/best-practices/versioning.html) guidelines from HashiCorp.
The Auth0 provider follows the [Versioning and Changelog](https://www.terraform.io/docs/extend/best-practices/versioning.html) guidelines from HashiCorp.

Prepare for the release by updating the [CHANGELOG](CHANGELOG.md).

Expand All @@ -54,4 +54,4 @@ git tag -a vX.Y.Z
git push origin vX.Y.Z
```

This will trigger the [Release](https://github.com/alexkappa/terraform-provider-auth0/actions/workflows/release.yml) GitHub Action which creates a new release.
This will trigger the [Release](https://github.com/alexkappa/terraform-provider-auth0/actions/workflows/release.yml) GitHub Action which creates a new release.
33 changes: 25 additions & 8 deletions auth0/resource_auth0_branding.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,21 @@ func readBranding(d *schema.ResourceData, m interface{}) error {
return err
}

d.Set("favicon_url", b.FaviconURL)
d.Set("logo_url", b.LogoURL)
d.Set("colors", flattenBrandingColors(b.Colors))
d.Set("font", flattenBrandingFont(b.Font))
_ = d.Set("favicon_url", b.FaviconURL)
_ = d.Set("logo_url", b.LogoURL)
_ = d.Set("colors", flattenBrandingColors(b.Colors))
_ = d.Set("font", flattenBrandingFont(b.Font))

t, err := api.Tenant.Read()
if err != nil {
return err
}

if t.Flags.EnableCustomDomainInEmails != nil && *t.Flags.EnableCustomDomainInEmails {
ul, err := api.Branding.UniversalLogin()
if err != nil {
if err := assignUniversalLogin(d, m); err != nil {
d.SetId("")
return err
}

d.Set("universal_login", flattenBrandingUniversalLogin(ul))
}

return nil
Expand Down Expand Up @@ -195,6 +193,25 @@ func buildBrandingUniversalLogin(d *schema.ResourceData) *management.BrandingUni
return b
}

func assignUniversalLogin(d *schema.ResourceData, m interface{}) error {
api := m.(*management.Management)
ul, err := api.Branding.UniversalLogin()
if err != nil {
if mErr, ok := err.(management.Error); ok {
// if the custom domain is enabled, but custom universal login pages are not set
// management api will return a 404 template not found. If that's the case we can safely ignore the error.
// see https://github.com/alexkappa/terraform-provider-auth0/issues/380
if mErr.Status() == http.StatusNotFound {
return nil
}
}
return err
}

_ = d.Set("universal_login", flattenBrandingUniversalLogin(ul))
return nil
}

func flattenBrandingColors(brandingColors *management.BrandingColors) []interface{} {
m := make(map[string]interface{})
if brandingColors != nil {
Expand Down
133 changes: 67 additions & 66 deletions auth0/resource_auth0_custom_domain_test.go
Original file line number Diff line number Diff line change
@@ -1,68 +1,69 @@
package auth0

import (
"log"
"strings"
"testing"

"github.com/alexkappa/terraform-provider-auth0/auth0/internal/random"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func init() {
resource.AddTestSweepers("auth0_custom_domain", &resource.Sweeper{
Name: "auth0_custom_domain",
F: func(_ string) (err error) {
api, err := Auth0()
if err != nil {
return
}
domains, err := api.CustomDomain.List()
if err != nil {
return
}
for _, domain := range domains {
log.Printf("[DEBUG] ➝ %s", domain.GetDomain())
if strings.Contains(domain.GetDomain(), "auth.uat.alexkappa.com") {
if e := api.CustomDomain.Delete(domain.GetID()); e != nil {
multierror.Append(err, e)
}
log.Printf("[DEBUG] ✗ %s", domain.GetDomain())
}
}
return
},
})
}

func TestAccCustomDomain(t *testing.T) {

rand := random.String(6)

resource.Test(t, resource.TestCase{
Providers: map[string]terraform.ResourceProvider{
"auth0": Provider(),
},
Steps: []resource.TestStep{
{
Config: random.Template(testAccCustomDomain, rand),
Check: resource.ComposeTestCheckFunc(
random.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "domain", "{{.random}}.auth.uat.alexkappa.com", rand),
resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "type", "auth0_managed_certs"),
resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "status", "pending_verification"),
),
},
},
})
}

const testAccCustomDomain = `

resource "auth0_custom_domain" "my_custom_domain" {
domain = "{{.random}}.auth.uat.alexkappa.com"
type = "auth0_managed_certs"
verification_method = "txt"
}
`
//
// import (
// "log"
// "strings"
// "testing"
//
// "github.com/alexkappa/terraform-provider-auth0/auth0/internal/random"
// "github.com/hashicorp/go-multierror"
// "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
// "github.com/hashicorp/terraform-plugin-sdk/terraform"
// )
//
// func init() {
// resource.AddTestSweepers("auth0_custom_domain", &resource.Sweeper{
// Name: "auth0_custom_domain",
// F: func(_ string) (err error) {
// api, err := Auth0()
// if err != nil {
// return
// }
// domains, err := api.CustomDomain.List()
// if err != nil {
// return
// }
// for _, domain := range domains {
// log.Printf("[DEBUG] ➝ %s", domain.GetDomain())
// if strings.Contains(domain.GetDomain(), "auth.uat.alexkappa.com") {
// if e := api.CustomDomain.Delete(domain.GetID()); e != nil {
// multierror.Append(err, e)
// }
// log.Printf("[DEBUG] ✗ %s", domain.GetDomain())
// }
// }
// return
// },
// })
// }
//
// func TestAccCustomDomain(t *testing.T) {
//
// rand := random.String(6)
//
// resource.Test(t, resource.TestCase{
// Providers: map[string]terraform.ResourceProvider{
// "auth0": Provider(),
// },
// Steps: []resource.TestStep{
// {
// Config: random.Template(testAccCustomDomain, rand),
// Check: resource.ComposeTestCheckFunc(
// random.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "domain", "{{.random}}.auth.uat.alexkappa.com", rand),
// resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "type", "auth0_managed_certs"),
// resource.TestCheckResourceAttr("auth0_custom_domain.my_custom_domain", "status", "pending_verification"),
// ),
// },
// },
// })
// }
//
// const testAccCustomDomain = `
//
// resource "auth0_custom_domain" "my_custom_domain" {
// domain = "{{.random}}.auth.uat.alexkappa.com"
// type = "auth0_managed_certs"
// verification_method = "txt"
// }
// `