Skip to content

Commit

Permalink
Merge pull request #65 from auth0/a0cli-49-custom-domains
Browse files Browse the repository at this point in the history
A0CLI-49: add initial custom-domains support
  • Loading branch information
rene00 authored Jan 27, 2021
2 parents 3cb6c70 + 597c1c6 commit d01a0a3
Show file tree
Hide file tree
Showing 15 changed files with 706 additions and 72 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ build-all-platforms:
# Run all the tests and code checks
ci: build-all-platforms test lint
.PHONY: ci

$(GOBIN)/mockgen:
@cd && GO111MODULE=on go get github.com/golang/mock/[email protected]

.PHONY: mocks
mocks: $(GOBIN)/mockgen
@go generate ./...
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/AlecAivazis/survey/v2 v2.2.7
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/briandowns/spinner v1.11.1
github.com/briandowns/spinner v1.12.0
github.com/fatih/color v1.9.0 // indirect
github.com/golang/mock v1.4.4
github.com/google/go-cmp v0.5.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/briandowns/spinner v1.11.1 h1:OixPqDEcX3juo5AjQZAnFPbeUA0jvkp2qzB5gOZJ/L0=
github.com/briandowns/spinner v1.11.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
github.com/briandowns/spinner v1.12.0 h1:72O0PzqGJb6G3KgrcIOtL/JAGGZ5ptOMCn9cUHmqsmw=
github.com/briandowns/spinner v1.12.0/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
Expand Down
5 changes: 0 additions & 5 deletions internal/ansi/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ func Spinner(text string, fn func() error) error {
s.FinalMSG = s.Prefix + spinnerTextFailed
}

// FIXME(cyx): this is causing a race condition. The problem is
// with our dependency on briandowns/spinner. For now adding an
// artificial sleep removes the race condition.
time.Sleep(time.Microsecond)

s.Stop()
}()

Expand Down
1 change: 1 addition & 0 deletions internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var requiredScopes = []string{
"create:rules", "delete:rules", "read:rules", "update:rules",
"read:client_keys", "read:logs",
"create:roles", "delete:roles", "read:roles", "update:roles",
"create:custom_domains", "delete:custom_domains", "read:custom_domains", "update:custom_domains",
}

type Authenticator struct {
Expand Down
2 changes: 2 additions & 0 deletions internal/auth0/auth0.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type API struct {
Rule RuleAPI
ResourceServer ResourceServerAPI
Role RoleAPI
CustomDomain CustomDomainAPI
}

func NewAPI(m *management.Management) *API {
Expand All @@ -30,6 +31,7 @@ func NewAPI(m *management.Management) *API {
ResourceServer: m.ResourceServer,
Rule: m.Rule,
Role: m.Role,
CustomDomain: m.CustomDomain,
}
}

Expand Down
22 changes: 22 additions & 0 deletions internal/auth0/custom_domain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:generate mockgen -source=custom_domain.go -destination=custom_domain_mock.go -package=auth0

package auth0

import "gopkg.in/auth0.v5/management"

type CustomDomainAPI interface {
// Create a new custom domain.
Create(r *management.CustomDomain, opts ...management.RequestOption) (err error)

// Retrieve a custom domain configuration and status.
Read(id string, opts ...management.RequestOption) (c *management.CustomDomain, err error)

// Run the verification process on a custom domain.
Verify(id string, opts ...management.RequestOption) (c *management.CustomDomain, err error)

// Delete a custom domain and stop serving requests for it.
Delete(id string, opts ...management.RequestOption) (err error)

// List all custom domains.
List(opts ...management.RequestOption) (c []*management.CustomDomain, err error)
}
131 changes: 131 additions & 0 deletions internal/auth0/custom_domain_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d01a0a3

Please sign in to comment.