Skip to content

Commit

Permalink
Implement auth-token commands (#409)
Browse files Browse the repository at this point in the history
* Implement auth-token commands

* fix help output tests

* order the commands

* clarify note about white-space delimited value

* username and password required

* fix help output test

* reverted adding in username/password

* add password required flag

* bump to go-fastly v4.0.0

* clarify ssl ciphers value

* reorder token list output columns

* print content of slice rather than raw slice output
  • Loading branch information
Integralist committed Sep 21, 2021
1 parent cd01012 commit fbef5e8
Show file tree
Hide file tree
Showing 308 changed files with 1,261 additions and 317 deletions.
2 changes: 1 addition & 1 deletion .tmpl/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewCreateCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion .tmpl/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewDeleteCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion .tmpl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/commands/compute/manifest"
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewDescribeCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion .tmpl/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewListCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion .tmpl/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/fastly/cli/pkg/app"
"github.com/fastly/cli/pkg/mock"
"github.com/fastly/cli/pkg/testutil"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

func TestCreate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion .tmpl/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewUpdateCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0
github.com/fastly/go-fastly/v3 v3.11.0
github.com/fastly/go-fastly/v4 v4.0.0
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible
github.com/fatih/color v1.12.0
github.com/frankban/quicktest v1.13.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5Jflh
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0 h1:90Ly+6UfUypEF6vvvW5rQIv9opIL8CbmW9FT20LDQoY=
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0/go.mod h1:V+Qd57rJe8gd4eiGzZyg4h54VLHmYVVw54iMnlAMrF8=
github.com/fastly/go-fastly/v3 v3.11.0 h1:OlaXJnSz470nwsB4vdNDk2J1or2UB1G9MSsDElxgqoM=
github.com/fastly/go-fastly/v3 v3.11.0/go.mod h1:KOaCWsmkIKSASPzADl8PT/bTQIghOw/eEaxlHOu3jMA=
github.com/fastly/go-fastly/v4 v4.0.0 h1:Drd/bFcig6Ex2WY1ifOaSiA5odCttsvmP2sQdbmHURU=
github.com/fastly/go-fastly/v4 v4.0.0/go.mod h1:ocFpevGC4Os3OcbdavJyJIrB7+X5c+m7UEQpUP+XgZs=
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible h1:FhrXlfhgGCS+uc6YwyiFUt04alnjpoX7vgDKJxS6Qbk=
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible/go.mod h1:U8UynVoU1SQaqD2I4ZqgYd5lx3A1ipQYn4aSt2Y5h6c=
github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
Expand Down
11 changes: 9 additions & 2 deletions pkg/api/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"net/http"

"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// HTTPClient models a concrete http.Client. It's a consumer contract for some
Expand All @@ -19,7 +19,6 @@ type HTTPClient interface {
type Interface interface {
AllIPs() (v4, v6 fastly.IPAddrs, err error)
AllDatacenters() (datacenters []fastly.Datacenter, err error)
GetTokenSelf() (*fastly.Token, error)

CreateService(*fastly.CreateServiceInput) (*fastly.Service, error)
ListServices(*fastly.ListServicesInput) ([]*fastly.Service, error)
Expand Down Expand Up @@ -276,6 +275,14 @@ type Interface interface {
ListCustomerUsers(i *fastly.ListCustomerUsersInput) ([]*fastly.User, error)
UpdateUser(i *fastly.UpdateUserInput) (*fastly.User, error)
ResetUserPassword(i *fastly.ResetUserPasswordInput) error

BatchDeleteTokens(i *fastly.BatchDeleteTokensInput) error
CreateToken(i *fastly.CreateTokenInput) (*fastly.Token, error)
DeleteToken(i *fastly.DeleteTokenInput) error
DeleteTokenSelf() error
GetTokenSelf() (*fastly.Token, error)
ListCustomerTokens(i *fastly.ListCustomerTokensInput) ([]*fastly.Token, error)
ListTokens() ([]*fastly.Token, error)
}

// RealtimeStatsInterface is the subset of go-fastly's realtime stats API used here.
Expand Down
13 changes: 12 additions & 1 deletion pkg/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/fastly/cli/pkg/cmd"
"github.com/fastly/cli/pkg/commands/acl"
"github.com/fastly/cli/pkg/commands/aclentry"
"github.com/fastly/cli/pkg/commands/authtoken"
"github.com/fastly/cli/pkg/commands/backend"
"github.com/fastly/cli/pkg/commands/compute"
"github.com/fastly/cli/pkg/commands/configure"
Expand Down Expand Up @@ -66,7 +67,7 @@ import (
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/revision"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
"github.com/fastly/kingpin"
)

Expand Down Expand Up @@ -156,6 +157,11 @@ func Run(opts RunOpts) error {
aclEntryDescribe := aclentry.NewDescribeCommand(aclEntryCmdRoot.CmdClause, &globals)
aclEntryList := aclentry.NewListCommand(aclEntryCmdRoot.CmdClause, &globals)
aclEntryUpdate := aclentry.NewUpdateCommand(aclEntryCmdRoot.CmdClause, &globals)
authtokenCmdRoot := authtoken.NewRootCommand(app, &globals)
authtokenCreate := authtoken.NewCreateCommand(authtokenCmdRoot.CmdClause, &globals)
authtokenDelete := authtoken.NewDeleteCommand(authtokenCmdRoot.CmdClause, &globals)
authtokenDescribe := authtoken.NewDescribeCommand(authtokenCmdRoot.CmdClause, &globals)
authtokenList := authtoken.NewListCommand(authtokenCmdRoot.CmdClause, &globals)
backendCmdRoot := backend.NewRootCommand(app, &globals)
backendCreate := backend.NewCreateCommand(backendCmdRoot.CmdClause, &globals)
backendDelete := backend.NewDeleteCommand(backendCmdRoot.CmdClause, &globals)
Expand Down Expand Up @@ -414,6 +420,11 @@ func Run(opts RunOpts) error {
aclEntryDescribe,
aclEntryList,
aclEntryUpdate,
authtokenCmdRoot,
authtokenCreate,
authtokenDelete,
authtokenDescribe,
authtokenList,
backendCmdRoot,
backendCreate,
backendDelete,
Expand Down
35 changes: 31 additions & 4 deletions pkg/app/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ COMMANDS
help Show help.
acl Manipulate Fastly ACLs (Access Control Lists)
acl-entry Manipulate Fastly ACL (Access Control List) entries
auth-token Manage API tokens for Fastly service users
backend Manipulate Fastly service version backends
compute Manage Compute@Edge packages
configure Configure the Fastly CLI
Expand Down Expand Up @@ -276,6 +277,34 @@ COMMANDS
--subnet=SUBNET Number of bits for the subnet mask applied to
the IP address
auth-token create --password=PASSWORD [<flags>]
Create an API token
--password=PASSWORD User password corresponding with --token or
$FASTLY_API_TOKEN
--expires=EXPIRES Time-stamp (UTC) of when the token will expire
--name=NAME Name of the token
--scope=SCOPE ... A comma-separated list of authorization scope
--services=SERVICES ... A comma-separated list of alphanumeric strings
identifying services (default: access to all
services)
auth-token delete [<flags>]
Revoke an API token
--current Revoke the token used to authenticate the request
--file=FILE Revoke tokens in bulk from a newline delimited list of tokens
--id=ID Alphanumeric string identifying a token
auth-token describe
Get the current API token
auth-token list [<flags>]
List API tokens
--customer-id=CUSTOMER-ID Alphanumeric string identifying the customer
backend create --version=VERSION --name=NAME --address=ADDRESS [<flags>]
Create a backend on a Fastly service version
Expand Down Expand Up @@ -335,8 +364,7 @@ COMMANDS
--max-tls-version=MAX-TLS-VERSION
Maximum allowed TLS version on SSL
connections to this backend
--ssl-ciphers=SSL-CIPHERS ...
List of OpenSSL ciphers (see
--ssl-ciphers=SSL-CIPHERS Colon delimited list of OpenSSL ciphers (see
https://www.openssl.org/docs/man1.0.2/man1/ciphers
for details)
Expand Down Expand Up @@ -428,8 +456,7 @@ COMMANDS
--max-tls-version=MAX-TLS-VERSION
Maximum allowed TLS version on SSL
connections to this backend
--ssl-ciphers=SSL-CIPHERS ...
List of OpenSSL ciphers (see
--ssl-ciphers=SSL-CIPHERS Colon delimited list of OpenSSL ciphers (see
https://www.openssl.org/docs/man1.0.2/man1/ciphers
for details)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/fastly/cli/pkg/env"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
"github.com/fastly/kingpin"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/fastly/cli/pkg/api"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
"github.com/fastly/kingpin"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/fastly/cli/pkg/cmd"
"github.com/fastly/cli/pkg/mock"
"github.com/fastly/cli/pkg/testutil"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

func TestOptionalServiceVersionParse(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/acl/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/fastly/cli/pkg/app"
"github.com/fastly/cli/pkg/mock"
"github.com/fastly/cli/pkg/testutil"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

func TestACLCreate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/acl/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewCreateCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/acl/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewDeleteCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/acl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/commands/compute/manifest"
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewDescribeCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/acl/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewListCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/acl/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewUpdateCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/aclentry/aclentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/fastly/cli/pkg/app"
"github.com/fastly/cli/pkg/mock"
"github.com/fastly/cli/pkg/testutil"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

func TestACLEntryCreate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/aclentry/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewCreateCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/aclentry/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewDeleteCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/aclentry/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/fastly/cli/pkg/commands/compute/manifest"
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewDescribeCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/aclentry/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewListCommand returns a usable command registered under the parent.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/aclentry/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/fastly/cli/pkg/config"
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v3/fastly"
"github.com/fastly/go-fastly/v4/fastly"
)

// NewUpdateCommand returns a usable command registered under the parent.
Expand Down
Loading

0 comments on commit fbef5e8

Please sign in to comment.