Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- feat(service/imageoptimizerdefaults): moved the `imageoptimizerdefaults` commands under the `service` command, with an unlisted and deprecated alias of `imageoptimizerdefaults` ([#1627](https://github.com/fastly/cli/pull/1627))
- feat(service/alert): moved the `alerts` command to the `service alert` command, with an unlisted and deprecated alias of `alerts` ([#1616](https://github.com/fastly/cli/pull/1626))
- feat(service/dictionary): moved the `dictionary` command under the `service` command, with an unlisted and deprecated alias of `dictionary` ([#1621](https://github.com/fastly/cli/pull/1630))
- feat(service/ratelimit): moved the `rate-limit` commands under the `service` command, with an unlisted and deprecated alias of `rate-limit` ([#1632](https://github.com/fastly/cli/pull/1632))

### Bug fixes:

Expand Down
1 change: 0 additions & 1 deletion pkg/app/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ object-storage
pops
products
profile
rate-limit
resource-link
secret-store
secret-store-entry
Expand Down
29 changes: 29 additions & 0 deletions pkg/commands/alias/ratelimit/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ratelimit

import (
"io"

newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"

"github.com/fastly/cli/pkg/argparser"
"github.com/fastly/cli/pkg/global"
"github.com/fastly/cli/pkg/text"
)

// CreateCommand wraps the CreateCommand from the newcmd package.
type CreateCommand struct {
*newcmd.CreateCommand
}

// NewCreateCommand returns a usable command registered under the parent.
func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateCommand {
c := CreateCommand{newcmd.NewCreateCommand(parent, g)}
c.CmdClause.Hidden()
return &c
}

// Exec implements the command interface.
func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error {
text.Deprecated(out, "Use the 'service rate-limit create' command instead.")
return c.CreateCommand.Exec(in, out)
}
29 changes: 29 additions & 0 deletions pkg/commands/alias/ratelimit/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ratelimit

import (
"io"

newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"

"github.com/fastly/cli/pkg/argparser"
"github.com/fastly/cli/pkg/global"
"github.com/fastly/cli/pkg/text"
)

// DeleteCommand wraps the DeleteCommand from the newcmd package.
type DeleteCommand struct {
*newcmd.DeleteCommand
}

// NewDeleteCommand returns a usable command registered under the parent.
func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteCommand {
c := DeleteCommand{newcmd.NewDeleteCommand(parent, g)}
c.CmdClause.Hidden()
return &c
}

// Exec implements the command interface.
func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error {
text.Deprecated(out, "Use the 'service rate-limit delete' command instead.")
return c.DeleteCommand.Exec(in, out)
}
31 changes: 31 additions & 0 deletions pkg/commands/alias/ratelimit/describe.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ratelimit

import (
"io"

newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"

"github.com/fastly/cli/pkg/argparser"
"github.com/fastly/cli/pkg/global"
"github.com/fastly/cli/pkg/text"
)

// DescribeCommand wraps the DescribeCommand from the newcmd package.
type DescribeCommand struct {
*newcmd.DescribeCommand
}

// NewDescribeCommand returns a usable command registered under the parent.
func NewDescribeCommand(parent argparser.Registerer, g *global.Data) *DescribeCommand {
c := DescribeCommand{newcmd.NewDescribeCommand(parent, g)}
c.CmdClause.Hidden()
return &c
}

// Exec implements the command interface.
func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error {
if !c.JSONOutput.Enabled {
text.Deprecated(out, "Use the 'service rate-limit describe' command instead.")
}
return c.DescribeCommand.Exec(in, out)
}
2 changes: 2 additions & 0 deletions pkg/commands/alias/ratelimit/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package ratelimit contains deprecated aliases for the 'service ratelimit' commands.
package ratelimit
31 changes: 31 additions & 0 deletions pkg/commands/alias/ratelimit/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ratelimit

import (
"io"

newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"

"github.com/fastly/cli/pkg/argparser"
"github.com/fastly/cli/pkg/global"
"github.com/fastly/cli/pkg/text"
)

// ListCommand wraps the ListCommand from the newcmd package.
type ListCommand struct {
*newcmd.ListCommand
}

// NewListCommand returns a usable command registered under the parent.
func NewListCommand(parent argparser.Registerer, g *global.Data) *ListCommand {
c := ListCommand{newcmd.NewListCommand(parent, g)}
c.CmdClause.Hidden()
return &c
}

// Exec implements the command interface.
func (c *ListCommand) Exec(in io.Reader, out io.Writer) error {
if !c.JSONOutput.Enabled {
text.Deprecated(out, "Use the 'service rate-limit list' command instead.")
}
return c.ListCommand.Exec(in, out)
}
31 changes: 31 additions & 0 deletions pkg/commands/alias/ratelimit/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ratelimit

import (
"io"

"github.com/fastly/cli/pkg/argparser"
"github.com/fastly/cli/pkg/global"
)

// RootCommand is the parent command for all subcommands in this package.
// It should be installed under the primary root command.
type RootCommand struct {
argparser.Base
// no flags
}

// CommandName is the string to be used to invoke this command.
const CommandName = "rate-limit"

// NewRootCommand returns a new command registered in the parent.
func NewRootCommand(parent argparser.Registerer, g *global.Data) *RootCommand {
var c RootCommand
c.Globals = g
c.CmdClause = parent.Command(CommandName, "Manipulate rate-limiters of the Fastly API and web interface").Hidden()
return &c
}

// Exec implements the command interface.
func (c *RootCommand) Exec(_ io.Reader, _ io.Writer) error {
panic("unreachable")
}
31 changes: 31 additions & 0 deletions pkg/commands/alias/ratelimit/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ratelimit

import (
"io"

newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"

"github.com/fastly/cli/pkg/argparser"
"github.com/fastly/cli/pkg/global"
"github.com/fastly/cli/pkg/text"
)

// UpdateCommand wraps the UpdateCommand from the newcmd package.
type UpdateCommand struct {
*newcmd.UpdateCommand
}

// NewUpdateCommand returns a usable command registered under the parent.
func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateCommand {
c := UpdateCommand{newcmd.NewUpdateCommand(parent, g)}
c.CmdClause.Hidden()
return &c
}

// Exec implements the command interface.
func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error {
if !c.JSONOutput.Enabled {
text.Deprecated(out, "Use the 'service rate-limit update' command instead.")
}
return c.UpdateCommand.Exec(in, out)
}
38 changes: 25 additions & 13 deletions pkg/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
aliashealthcheck "github.com/fastly/cli/pkg/commands/alias/healthcheck"
aliasimageoptimizerdefaults "github.com/fastly/cli/pkg/commands/alias/imageoptimizerdefaults"
aliaspurge "github.com/fastly/cli/pkg/commands/alias/purge"
aliasratelimit "github.com/fastly/cli/pkg/commands/alias/ratelimit"
aliasserviceversion "github.com/fastly/cli/pkg/commands/alias/serviceversion"
aliasvcl "github.com/fastly/cli/pkg/commands/alias/vcl"
aliasvclcondition "github.com/fastly/cli/pkg/commands/alias/vcl/condition"
Expand Down Expand Up @@ -93,7 +94,6 @@ import (
"github.com/fastly/cli/pkg/commands/pop"
"github.com/fastly/cli/pkg/commands/products"
"github.com/fastly/cli/pkg/commands/profile"
"github.com/fastly/cli/pkg/commands/ratelimit"
"github.com/fastly/cli/pkg/commands/resourcelink"
"github.com/fastly/cli/pkg/commands/secretstore"
"github.com/fastly/cli/pkg/commands/secretstoreentry"
Expand All @@ -107,6 +107,7 @@ import (
servicehealthcheck "github.com/fastly/cli/pkg/commands/service/healthcheck"
serviceimageoptimizerdefaults "github.com/fastly/cli/pkg/commands/service/imageoptimizerdefaults"
servicepurge "github.com/fastly/cli/pkg/commands/service/purge"
serviceratelimit "github.com/fastly/cli/pkg/commands/service/ratelimit"
servicevcl "github.com/fastly/cli/pkg/commands/service/vcl"
servicevclcondition "github.com/fastly/cli/pkg/commands/service/vcl/condition"
servicevclcustom "github.com/fastly/cli/pkg/commands/service/vcl/custom"
Expand Down Expand Up @@ -559,12 +560,6 @@ func Define( // nolint:revive // function-length
profileSwitch := profile.NewSwitchCommand(profileCmdRoot.CmdClause, data, ssoCmdRoot)
profileToken := profile.NewTokenCommand(profileCmdRoot.CmdClause, data)
profileUpdate := profile.NewUpdateCommand(profileCmdRoot.CmdClause, data, ssoCmdRoot)
rateLimitCmdRoot := ratelimit.NewRootCommand(app, data)
rateLimitCreate := ratelimit.NewCreateCommand(rateLimitCmdRoot.CmdClause, data)
rateLimitDelete := ratelimit.NewDeleteCommand(rateLimitCmdRoot.CmdClause, data)
rateLimitDescribe := ratelimit.NewDescribeCommand(rateLimitCmdRoot.CmdClause, data)
rateLimitList := ratelimit.NewListCommand(rateLimitCmdRoot.CmdClause, data)
rateLimitUpdate := ratelimit.NewUpdateCommand(rateLimitCmdRoot.CmdClause, data)
resourcelinkCmdRoot := resourcelink.NewRootCommand(app, data)
resourcelinkCreate := resourcelink.NewCreateCommand(resourcelinkCmdRoot.CmdClause, data)
resourcelinkDelete := resourcelink.NewDeleteCommand(resourcelinkCmdRoot.CmdClause, data)
Expand Down Expand Up @@ -671,6 +666,12 @@ func Define( // nolint:revive // function-length
serviceimageoptimizerdefaultsCmdRoot := serviceimageoptimizerdefaults.NewRootCommand(serviceCmdRoot.CmdClause, data)
serviceimageoptimizerdefaultsGet := serviceimageoptimizerdefaults.NewGetCommand(serviceimageoptimizerdefaultsCmdRoot.CmdClause, data)
serviceimageoptimizerdefaultsUpdate := serviceimageoptimizerdefaults.NewUpdateCommand(serviceimageoptimizerdefaultsCmdRoot.CmdClause, data)
serviceratelimitCmdRoot := serviceratelimit.NewRootCommand(serviceCmdRoot.CmdClause, data)
serviceratelimitCreate := serviceratelimit.NewCreateCommand(serviceratelimitCmdRoot.CmdClause, data)
serviceratelimitDelete := serviceratelimit.NewDeleteCommand(serviceratelimitCmdRoot.CmdClause, data)
serviceratelimitDescribe := serviceratelimit.NewDescribeCommand(serviceratelimitCmdRoot.CmdClause, data)
serviceratelimitList := serviceratelimit.NewListCommand(serviceratelimitCmdRoot.CmdClause, data)
serviceratelimitUpdate := serviceratelimit.NewUpdateCommand(serviceratelimitCmdRoot.CmdClause, data)
statsCmdRoot := stats.NewRootCommand(app, data)
statsHistorical := stats.NewHistoricalCommand(statsCmdRoot.CmdClause, data)
statsRealtime := stats.NewRealtimeCommand(statsCmdRoot.CmdClause, data)
Expand Down Expand Up @@ -767,6 +768,12 @@ func Define( // nolint:revive // function-length
aliasACLEntryDescribe := aliasaclentry.NewDescribeCommand(aliasACLEntryRoot.CmdClause, data)
aliasACLEntryList := aliasaclentry.NewListCommand(aliasACLEntryRoot.CmdClause, data)
aliasACLEntryUpdate := aliasaclentry.NewUpdateCommand(aliasACLEntryRoot.CmdClause, data)
aliasRateLimitRoot := aliasratelimit.NewRootCommand(app, data)
aliasRateLimitCreate := aliasratelimit.NewCreateCommand(aliasRateLimitRoot.CmdClause, data)
aliasRateLimitDelete := aliasratelimit.NewDeleteCommand(aliasRateLimitRoot.CmdClause, data)
aliasRateLimitDescribe := aliasratelimit.NewDescribeCommand(aliasRateLimitRoot.CmdClause, data)
aliasRateLimitList := aliasratelimit.NewListCommand(aliasRateLimitRoot.CmdClause, data)
aliasRateLimitUpdate := aliasratelimit.NewUpdateCommand(aliasRateLimitRoot.CmdClause, data)
aliasVclRoot := aliasvcl.NewRootCommand(app, data)
aliasVclDescribe := aliasvcl.NewDescribeCommand(aliasVclRoot.CmdClause, data)
aliasVclConditionRoot := aliasvclcondition.NewRootCommand(aliasVclRoot.CmdClause, data)
Expand Down Expand Up @@ -1206,12 +1213,6 @@ func Define( // nolint:revive // function-length
profileSwitch,
profileToken,
profileUpdate,
rateLimitCmdRoot,
rateLimitCreate,
rateLimitDelete,
rateLimitDescribe,
rateLimitList,
rateLimitUpdate,
resourcelinkCmdRoot,
resourcelinkCreate,
resourcelinkDelete,
Expand Down Expand Up @@ -1306,6 +1307,12 @@ func Define( // nolint:revive // function-length
serviceimageoptimizerdefaultsCmdRoot,
serviceimageoptimizerdefaultsGet,
serviceimageoptimizerdefaultsUpdate,
serviceratelimitCmdRoot,
serviceratelimitCreate,
serviceratelimitDelete,
serviceratelimitDescribe,
serviceratelimitList,
serviceratelimitUpdate,
serviceVersionActivate,
serviceVersionClone,
serviceVersionCmdRoot,
Expand Down Expand Up @@ -1404,6 +1411,11 @@ func Define( // nolint:revive // function-length
aliasACLEntryDescribe,
aliasACLEntryList,
aliasACLEntryUpdate,
aliasRateLimitCreate,
aliasRateLimitDelete,
aliasRateLimitDescribe,
aliasRateLimitList,
aliasRateLimitUpdate,
aliasVclDescribe,
aliasVclConditionCreate,
aliasVclConditionDelete,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (

"github.com/fastly/go-fastly/v12/fastly"

root "github.com/fastly/cli/pkg/commands/ratelimit"
root "github.com/fastly/cli/pkg/commands/service"
sub "github.com/fastly/cli/pkg/commands/service/ratelimit"
"github.com/fastly/cli/pkg/mock"
"github.com/fastly/cli/pkg/testutil"
)
Expand Down Expand Up @@ -40,7 +41,7 @@ func TestRateLimitCreate(t *testing.T) {
},
}

testutil.RunCLIScenarios(t, []string{root.CommandName, "create"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "create"}, scenarios)
}

func TestRateLimitDelete(t *testing.T) {
Expand All @@ -67,7 +68,7 @@ func TestRateLimitDelete(t *testing.T) {
},
}

testutil.RunCLIScenarios(t, []string{root.CommandName, "delete"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "delete"}, scenarios)
}

func TestRateLimitDescribe(t *testing.T) {
Expand Down Expand Up @@ -101,7 +102,7 @@ func TestRateLimitDescribe(t *testing.T) {
},
}

testutil.RunCLIScenarios(t, []string{root.CommandName, "describe"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "describe"}, scenarios)
}

func TestRateLimitList(t *testing.T) {
Expand Down Expand Up @@ -139,7 +140,7 @@ func TestRateLimitList(t *testing.T) {
},
}

testutil.RunCLIScenarios(t, []string{root.CommandName, "list"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "list"}, scenarios)
}

func TesRateLimittUpdate(t *testing.T) {
Expand Down Expand Up @@ -169,5 +170,5 @@ func TesRateLimittUpdate(t *testing.T) {
},
}

testutil.RunCLIScenarios(t, []string{root.CommandName, "update"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "update"}, scenarios)
}