Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump go-fastly to v7 #707

Merged
merged 18 commits into from
Nov 19, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/bep/debounce v1.2.1
github.com/blang/semver v3.5.1+incompatible
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0
github.com/fastly/go-fastly/v6 v6.8.0
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible
github.com/fatih/color v1.13.0
github.com/frankban/quicktest v1.13.1 // indirect
Expand All @@ -31,6 +30,7 @@ require (
)

require (
github.com/fastly/go-fastly/v7 v7.0.0
github.com/kennygrant/sanitize v1.2.4
github.com/mholt/archiver v3.1.1+incompatible
github.com/otiai10/copy v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj6
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/v6 v6.8.0 h1:Y5B3S5chYB2YCNDoKWYM8CK0mc5JxayTU/aneCgJfx8=
github.com/fastly/go-fastly/v6 v6.8.0/go.mod h1:NrIbx45etTFv35rgfRe+eQY+8kA47arWABIkOaQ+roY=
github.com/fastly/go-fastly/v7 v7.0.0 h1:Qz6AHosQtSbp8u3aQyGruXNFF/yAqvvjaUCNvTM1XS4=
github.com/fastly/go-fastly/v7 v7.0.0/go.mod h1:WdssHSSIe41/a5juIJagw8MCTA9m7xQ1TVLRcBQQuS8=
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.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
Expand Down
4 changes: 2 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/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
)

// HTTPClient models a concrete http.Client. It's a consumer contract for some
Expand Down Expand Up @@ -322,7 +322,7 @@ type Interface interface {
ListTLSSubscriptions(i *fastly.ListTLSSubscriptionsInput) ([]*fastly.TLSSubscription, error)
UpdateTLSSubscription(i *fastly.UpdateTLSSubscriptionInput) (*fastly.TLSSubscription, error)

ListServiceAuthorizations(i *fastly.ListServiceAuthorizationsInput) (*fastly.SAResponse, error)
ListServiceAuthorizations(i *fastly.ListServiceAuthorizationsInput) (*fastly.ServiceAuthorizations, error)
GetServiceAuthorization(i *fastly.GetServiceAuthorizationInput) (*fastly.ServiceAuthorization, error)
CreateServiceAuthorization(i *fastly.CreateServiceAuthorizationInput) (*fastly.ServiceAuthorization, error)
UpdateServiceAuthorization(i *fastly.UpdateServiceAuthorizationInput) (*fastly.ServiceAuthorization, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/fastly/cli/pkg/profile"
"github.com/fastly/cli/pkg/revision"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
"github.com/fastly/kingpin"
)

Expand Down
14 changes: 1 addition & 13 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
fsterr "github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/manifest"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
"github.com/fastly/kingpin"
)

Expand Down Expand Up @@ -92,18 +92,6 @@ type OptionalBool struct {
Value bool
}

// OptionalUint models an optional uint flag value.
type OptionalUint struct {
Optional
Value uint
}

// OptionalUint8 models an optional unit8 flag value.
type OptionalUint8 struct {
Optional
Value uint8
}

// OptionalInt models an optional int flag value.
type OptionalInt struct {
Optional
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/fastly/cli/pkg/env"
fsterr "github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v6/fastly"
"github.com/fastly/go-fastly/v7/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/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
)

func TestOptionalServiceVersionParse(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions 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/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
)

func TestACLCreate(t *testing.T) {
Expand All @@ -16,7 +16,7 @@ func TestACLCreate(t *testing.T) {
{
Name: "validate missing --name flag",
Args: args("acl create --version 3"),
WantError: "error parsing arguments: required flag --name not provided",
WantError: "error reading service: no service ID found",
},
{
Name: "validate missing --version flag",
Expand Down Expand Up @@ -54,7 +54,7 @@ func TestACLCreate(t *testing.T) {
CreateACLFn: func(i *fastly.CreateACLInput) (*fastly.ACL, error) {
return &fastly.ACL{
ID: "456",
Name: i.Name,
Name: *i.Name,
ServiceID: i.ServiceID,
ServiceVersion: i.ServiceVersion,
}, nil
Expand All @@ -71,7 +71,7 @@ func TestACLCreate(t *testing.T) {
CreateACLFn: func(i *fastly.CreateACLInput) (*fastly.ACL, error) {
return &fastly.ACL{
ID: "456",
Name: i.Name,
Name: *i.Name,
ServiceID: i.ServiceID,
ServiceVersion: i.ServiceVersion,
}, nil
Expand Down Expand Up @@ -347,7 +347,7 @@ func TestACLUpdate(t *testing.T) {
UpdateACLFn: func(i *fastly.UpdateACLInput) (*fastly.ACL, error) {
return &fastly.ACL{
ID: "456",
Name: i.NewName,
Name: *i.NewName,
ServiceID: i.ServiceID,
ServiceVersion: i.ServiceVersion,
}, nil
Expand All @@ -364,7 +364,7 @@ func TestACLUpdate(t *testing.T) {
UpdateACLFn: func(i *fastly.UpdateACLInput) (*fastly.ACL, error) {
return &fastly.ACL{
ID: "456",
Name: i.NewName,
Name: *i.NewName,
ServiceID: i.ServiceID,
ServiceVersion: i.ServiceVersion,
}, nil
Expand Down
33 changes: 19 additions & 14 deletions pkg/commands/acl/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,34 @@ import (
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/manifest"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
)

// NewCreateCommand returns a usable command registered under the parent.
func NewCreateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *CreateCommand {
var c CreateCommand
c := CreateCommand{
Base: cmd.Base{
Globals: globals,
},
manifest: data,
}

c.CmdClause = parent.Command("create", "Create a new ACL attached to the specified service version").Alias("add")
c.Globals = globals
c.manifest = data

// Required flags
c.CmdClause.Flag("name", "Name for the ACL. Must start with an alphanumeric character and contain only alphanumeric characters, underscores, and whitespace").Required().StringVar(&c.name)
// required
c.RegisterFlag(cmd.StringFlagOpts{
Name: cmd.FlagVersionName,
Description: cmd.FlagVersionDesc,
Dst: &c.serviceVersion.Value,
Required: true,
})

// Optional flags
// optional
c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{
Action: c.autoClone.Set,
Dst: &c.autoClone.Value,
})
c.CmdClause.Flag("name", "Name for the ACL. Must start with an alphanumeric character and contain only alphanumeric characters, underscores, and whitespace").Action(c.name.Set).StringVar(&c.name.Value)
c.RegisterFlag(cmd.StringFlagOpts{
Name: cmd.FlagServiceIDName,
Description: cmd.FlagServiceIDDesc,
Expand All @@ -54,7 +58,7 @@ type CreateCommand struct {

autoClone cmd.OptionalAutoClone
manifest manifest.Data
name string
name cmd.OptionalString
serviceName cmd.OptionalServiceNameID
serviceVersion cmd.OptionalServiceVersion
}
Expand Down Expand Up @@ -96,11 +100,12 @@ func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error {

// constructInput transforms values parsed from CLI flags into an object to be used by the API client library.
func (c *CreateCommand) constructInput(serviceID string, serviceVersion int) *fastly.CreateACLInput {
var input fastly.CreateACLInput

input.Name = c.name
input.ServiceID = serviceID
input.ServiceVersion = serviceVersion

input := fastly.CreateACLInput{
ServiceID: serviceID,
ServiceVersion: serviceVersion,
}
if c.name.WasSet {
input.Name = &c.name.Value
}
return &input
}
15 changes: 9 additions & 6 deletions pkg/commands/acl/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ import (
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/manifest"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
)

// NewDeleteCommand returns a usable command registered under the parent.
func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DeleteCommand {
var c DeleteCommand
c := DeleteCommand{
Base: cmd.Base{
Globals: globals,
},
manifest: data,
}
c.CmdClause = parent.Command("delete", "Delete an ACL from the specified service version").Alias("remove")
c.Globals = globals
c.manifest = data

// Required flags
// required
c.CmdClause.Flag("name", "The name of the ACL to delete").Required().StringVar(&c.name)
c.RegisterFlag(cmd.StringFlagOpts{
Name: cmd.FlagVersionName,
Expand All @@ -27,7 +30,7 @@ func NewDeleteCommand(parent cmd.Registerer, globals *config.Data, data manifest
Required: true,
})

// Optional flags
// optional
c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{
Action: c.autoClone.Set,
Dst: &c.autoClone.Value,
Expand Down
15 changes: 9 additions & 6 deletions pkg/commands/acl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ import (
"github.com/fastly/cli/pkg/config"
fsterr "github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/manifest"
"github.com/fastly/go-fastly/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
)

// NewDescribeCommand returns a usable command registered under the parent.
func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *DescribeCommand {
var c DescribeCommand
c := DescribeCommand{
Base: cmd.Base{
Globals: globals,
},
manifest: data,
}
c.CmdClause = parent.Command("describe", "Retrieve a single ACL by name for the version and service").Alias("get")
c.Globals = globals
c.manifest = data

// Required flags
// required
c.CmdClause.Flag("name", "The name of the ACL").Required().StringVar(&c.name)
c.RegisterFlag(cmd.StringFlagOpts{
Name: cmd.FlagVersionName,
Expand All @@ -28,7 +31,7 @@ func NewDescribeCommand(parent cmd.Registerer, globals *config.Data, data manife
Required: true,
})

// Optional Flags
// optional
c.RegisterFlagBool(cmd.BoolFlagOpts{
Name: cmd.FlagJSONName,
Description: cmd.FlagJSONDesc,
Expand Down
15 changes: 9 additions & 6 deletions pkg/commands/acl/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@ import (
fsterr "github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/manifest"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
)

// NewListCommand returns a usable command registered under the parent.
func NewListCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *ListCommand {
var c ListCommand
c := ListCommand{
Base: cmd.Base{
Globals: globals,
},
manifest: data,
}
c.CmdClause = parent.Command("list", "List ACLs")
c.Globals = globals
c.manifest = data

// Required flags
// required
c.RegisterFlag(cmd.StringFlagOpts{
Name: cmd.FlagVersionName,
Description: cmd.FlagVersionDesc,
Dst: &c.serviceVersion.Value,
Required: true,
})

// Optional Flags
// optional
c.RegisterFlagBool(cmd.BoolFlagOpts{
Name: cmd.FlagJSONName,
Description: cmd.FlagJSONDesc,
Expand Down
17 changes: 10 additions & 7 deletions pkg/commands/acl/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ import (
"github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/manifest"
"github.com/fastly/cli/pkg/text"
"github.com/fastly/go-fastly/v6/fastly"
"github.com/fastly/go-fastly/v7/fastly"
)

// NewUpdateCommand returns a usable command registered under the parent.
func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest.Data) *UpdateCommand {
var c UpdateCommand
c := UpdateCommand{
Base: cmd.Base{
Globals: globals,
},
manifest: data,
}
c.CmdClause = parent.Command("update", "Update an ACL for a particular service and version")
c.Globals = globals
c.manifest = data

// Required flags
// required
c.CmdClause.Flag("name", "The name of the ACL to update").Required().StringVar(&c.name)
c.CmdClause.Flag("new-name", "The new name of the ACL").Required().StringVar(&c.newName)
c.RegisterFlag(cmd.StringFlagOpts{
Expand All @@ -28,7 +31,7 @@ func NewUpdateCommand(parent cmd.Registerer, globals *config.Data, data manifest
Required: true,
})

// Optional flags
// optional
c.RegisterAutoCloneFlag(cmd.AutoCloneFlagOpts{
Action: c.autoClone.Set,
Dst: &c.autoClone.Value,
Expand Down Expand Up @@ -100,7 +103,7 @@ func (c *UpdateCommand) constructInput(serviceID string, serviceVersion int) *fa
var input fastly.UpdateACLInput

input.Name = c.name
input.NewName = c.newName
input.NewName = &c.newName
input.ServiceID = serviceID
input.ServiceVersion = serviceVersion

Expand Down
Loading