Skip to content

Commit 88774e8

Browse files
authored
[CDTOOL-1261] Move rate-limit command under service (#1632)
### Change summary This PR moves the `rate-limit` command under the service command. A alias for `fastly rate-limit` is added here to prevent breaking changes. All Submissions: * [x] Have you followed the guidelines in our Contributing document? * [x] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/fastly/cli/pulls) for the same update/change? <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### New Feature Submissions: * [ ] Does your submission pass tests? ### User Impact None, an alias was created to prevent breaking changes.
1 parent e0bc0f5 commit 88774e8

18 files changed

Lines changed: 217 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- 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))
2222
- 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))
2323
- 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))
24+
- 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))
2425

2526
### Bug fixes:
2627

pkg/app/run_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ object-storage
7979
pops
8080
products
8181
profile
82-
rate-limit
8382
resource-link
8483
secret-store
8584
secret-store-entry
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package ratelimit
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"
7+
8+
"github.com/fastly/cli/pkg/argparser"
9+
"github.com/fastly/cli/pkg/global"
10+
"github.com/fastly/cli/pkg/text"
11+
)
12+
13+
// CreateCommand wraps the CreateCommand from the newcmd package.
14+
type CreateCommand struct {
15+
*newcmd.CreateCommand
16+
}
17+
18+
// NewCreateCommand returns a usable command registered under the parent.
19+
func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateCommand {
20+
c := CreateCommand{newcmd.NewCreateCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error {
27+
text.Deprecated(out, "Use the 'service rate-limit create' command instead.")
28+
return c.CreateCommand.Exec(in, out)
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package ratelimit
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"
7+
8+
"github.com/fastly/cli/pkg/argparser"
9+
"github.com/fastly/cli/pkg/global"
10+
"github.com/fastly/cli/pkg/text"
11+
)
12+
13+
// DeleteCommand wraps the DeleteCommand from the newcmd package.
14+
type DeleteCommand struct {
15+
*newcmd.DeleteCommand
16+
}
17+
18+
// NewDeleteCommand returns a usable command registered under the parent.
19+
func NewDeleteCommand(parent argparser.Registerer, g *global.Data) *DeleteCommand {
20+
c := DeleteCommand{newcmd.NewDeleteCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *DeleteCommand) Exec(in io.Reader, out io.Writer) error {
27+
text.Deprecated(out, "Use the 'service rate-limit delete' command instead.")
28+
return c.DeleteCommand.Exec(in, out)
29+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ratelimit
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"
7+
8+
"github.com/fastly/cli/pkg/argparser"
9+
"github.com/fastly/cli/pkg/global"
10+
"github.com/fastly/cli/pkg/text"
11+
)
12+
13+
// DescribeCommand wraps the DescribeCommand from the newcmd package.
14+
type DescribeCommand struct {
15+
*newcmd.DescribeCommand
16+
}
17+
18+
// NewDescribeCommand returns a usable command registered under the parent.
19+
func NewDescribeCommand(parent argparser.Registerer, g *global.Data) *DescribeCommand {
20+
c := DescribeCommand{newcmd.NewDescribeCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error {
27+
if !c.JSONOutput.Enabled {
28+
text.Deprecated(out, "Use the 'service rate-limit describe' command instead.")
29+
}
30+
return c.DescribeCommand.Exec(in, out)
31+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package ratelimit contains deprecated aliases for the 'service ratelimit' commands.
2+
package ratelimit
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ratelimit
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"
7+
8+
"github.com/fastly/cli/pkg/argparser"
9+
"github.com/fastly/cli/pkg/global"
10+
"github.com/fastly/cli/pkg/text"
11+
)
12+
13+
// ListCommand wraps the ListCommand from the newcmd package.
14+
type ListCommand struct {
15+
*newcmd.ListCommand
16+
}
17+
18+
// NewListCommand returns a usable command registered under the parent.
19+
func NewListCommand(parent argparser.Registerer, g *global.Data) *ListCommand {
20+
c := ListCommand{newcmd.NewListCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *ListCommand) Exec(in io.Reader, out io.Writer) error {
27+
if !c.JSONOutput.Enabled {
28+
text.Deprecated(out, "Use the 'service rate-limit list' command instead.")
29+
}
30+
return c.ListCommand.Exec(in, out)
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ratelimit
2+
3+
import (
4+
"io"
5+
6+
"github.com/fastly/cli/pkg/argparser"
7+
"github.com/fastly/cli/pkg/global"
8+
)
9+
10+
// RootCommand is the parent command for all subcommands in this package.
11+
// It should be installed under the primary root command.
12+
type RootCommand struct {
13+
argparser.Base
14+
// no flags
15+
}
16+
17+
// CommandName is the string to be used to invoke this command.
18+
const CommandName = "rate-limit"
19+
20+
// NewRootCommand returns a new command registered in the parent.
21+
func NewRootCommand(parent argparser.Registerer, g *global.Data) *RootCommand {
22+
var c RootCommand
23+
c.Globals = g
24+
c.CmdClause = parent.Command(CommandName, "Manipulate rate-limiters of the Fastly API and web interface").Hidden()
25+
return &c
26+
}
27+
28+
// Exec implements the command interface.
29+
func (c *RootCommand) Exec(_ io.Reader, _ io.Writer) error {
30+
panic("unreachable")
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ratelimit
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/ratelimit"
7+
8+
"github.com/fastly/cli/pkg/argparser"
9+
"github.com/fastly/cli/pkg/global"
10+
"github.com/fastly/cli/pkg/text"
11+
)
12+
13+
// UpdateCommand wraps the UpdateCommand from the newcmd package.
14+
type UpdateCommand struct {
15+
*newcmd.UpdateCommand
16+
}
17+
18+
// NewUpdateCommand returns a usable command registered under the parent.
19+
func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateCommand {
20+
c := UpdateCommand{newcmd.NewUpdateCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error {
27+
if !c.JSONOutput.Enabled {
28+
text.Deprecated(out, "Use the 'service rate-limit update' command instead.")
29+
}
30+
return c.UpdateCommand.Exec(in, out)
31+
}

pkg/commands/commands.go

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
aliashealthcheck "github.com/fastly/cli/pkg/commands/alias/healthcheck"
1313
aliasimageoptimizerdefaults "github.com/fastly/cli/pkg/commands/alias/imageoptimizerdefaults"
1414
aliaspurge "github.com/fastly/cli/pkg/commands/alias/purge"
15+
aliasratelimit "github.com/fastly/cli/pkg/commands/alias/ratelimit"
1516
aliasserviceversion "github.com/fastly/cli/pkg/commands/alias/serviceversion"
1617
aliasvcl "github.com/fastly/cli/pkg/commands/alias/vcl"
1718
aliasvclcondition "github.com/fastly/cli/pkg/commands/alias/vcl/condition"
@@ -93,7 +94,6 @@ import (
9394
"github.com/fastly/cli/pkg/commands/pop"
9495
"github.com/fastly/cli/pkg/commands/products"
9596
"github.com/fastly/cli/pkg/commands/profile"
96-
"github.com/fastly/cli/pkg/commands/ratelimit"
9797
"github.com/fastly/cli/pkg/commands/resourcelink"
9898
"github.com/fastly/cli/pkg/commands/secretstore"
9999
"github.com/fastly/cli/pkg/commands/secretstoreentry"
@@ -107,6 +107,7 @@ import (
107107
servicehealthcheck "github.com/fastly/cli/pkg/commands/service/healthcheck"
108108
serviceimageoptimizerdefaults "github.com/fastly/cli/pkg/commands/service/imageoptimizerdefaults"
109109
servicepurge "github.com/fastly/cli/pkg/commands/service/purge"
110+
serviceratelimit "github.com/fastly/cli/pkg/commands/service/ratelimit"
110111
servicevcl "github.com/fastly/cli/pkg/commands/service/vcl"
111112
servicevclcondition "github.com/fastly/cli/pkg/commands/service/vcl/condition"
112113
servicevclcustom "github.com/fastly/cli/pkg/commands/service/vcl/custom"
@@ -559,12 +560,6 @@ func Define( // nolint:revive // function-length
559560
profileSwitch := profile.NewSwitchCommand(profileCmdRoot.CmdClause, data, ssoCmdRoot)
560561
profileToken := profile.NewTokenCommand(profileCmdRoot.CmdClause, data)
561562
profileUpdate := profile.NewUpdateCommand(profileCmdRoot.CmdClause, data, ssoCmdRoot)
562-
rateLimitCmdRoot := ratelimit.NewRootCommand(app, data)
563-
rateLimitCreate := ratelimit.NewCreateCommand(rateLimitCmdRoot.CmdClause, data)
564-
rateLimitDelete := ratelimit.NewDeleteCommand(rateLimitCmdRoot.CmdClause, data)
565-
rateLimitDescribe := ratelimit.NewDescribeCommand(rateLimitCmdRoot.CmdClause, data)
566-
rateLimitList := ratelimit.NewListCommand(rateLimitCmdRoot.CmdClause, data)
567-
rateLimitUpdate := ratelimit.NewUpdateCommand(rateLimitCmdRoot.CmdClause, data)
568563
resourcelinkCmdRoot := resourcelink.NewRootCommand(app, data)
569564
resourcelinkCreate := resourcelink.NewCreateCommand(resourcelinkCmdRoot.CmdClause, data)
570565
resourcelinkDelete := resourcelink.NewDeleteCommand(resourcelinkCmdRoot.CmdClause, data)
@@ -671,6 +666,12 @@ func Define( // nolint:revive // function-length
671666
serviceimageoptimizerdefaultsCmdRoot := serviceimageoptimizerdefaults.NewRootCommand(serviceCmdRoot.CmdClause, data)
672667
serviceimageoptimizerdefaultsGet := serviceimageoptimizerdefaults.NewGetCommand(serviceimageoptimizerdefaultsCmdRoot.CmdClause, data)
673668
serviceimageoptimizerdefaultsUpdate := serviceimageoptimizerdefaults.NewUpdateCommand(serviceimageoptimizerdefaultsCmdRoot.CmdClause, data)
669+
serviceratelimitCmdRoot := serviceratelimit.NewRootCommand(serviceCmdRoot.CmdClause, data)
670+
serviceratelimitCreate := serviceratelimit.NewCreateCommand(serviceratelimitCmdRoot.CmdClause, data)
671+
serviceratelimitDelete := serviceratelimit.NewDeleteCommand(serviceratelimitCmdRoot.CmdClause, data)
672+
serviceratelimitDescribe := serviceratelimit.NewDescribeCommand(serviceratelimitCmdRoot.CmdClause, data)
673+
serviceratelimitList := serviceratelimit.NewListCommand(serviceratelimitCmdRoot.CmdClause, data)
674+
serviceratelimitUpdate := serviceratelimit.NewUpdateCommand(serviceratelimitCmdRoot.CmdClause, data)
674675
statsCmdRoot := stats.NewRootCommand(app, data)
675676
statsHistorical := stats.NewHistoricalCommand(statsCmdRoot.CmdClause, data)
676677
statsRealtime := stats.NewRealtimeCommand(statsCmdRoot.CmdClause, data)
@@ -767,6 +768,12 @@ func Define( // nolint:revive // function-length
767768
aliasACLEntryDescribe := aliasaclentry.NewDescribeCommand(aliasACLEntryRoot.CmdClause, data)
768769
aliasACLEntryList := aliasaclentry.NewListCommand(aliasACLEntryRoot.CmdClause, data)
769770
aliasACLEntryUpdate := aliasaclentry.NewUpdateCommand(aliasACLEntryRoot.CmdClause, data)
771+
aliasRateLimitRoot := aliasratelimit.NewRootCommand(app, data)
772+
aliasRateLimitCreate := aliasratelimit.NewCreateCommand(aliasRateLimitRoot.CmdClause, data)
773+
aliasRateLimitDelete := aliasratelimit.NewDeleteCommand(aliasRateLimitRoot.CmdClause, data)
774+
aliasRateLimitDescribe := aliasratelimit.NewDescribeCommand(aliasRateLimitRoot.CmdClause, data)
775+
aliasRateLimitList := aliasratelimit.NewListCommand(aliasRateLimitRoot.CmdClause, data)
776+
aliasRateLimitUpdate := aliasratelimit.NewUpdateCommand(aliasRateLimitRoot.CmdClause, data)
770777
aliasVclRoot := aliasvcl.NewRootCommand(app, data)
771778
aliasVclDescribe := aliasvcl.NewDescribeCommand(aliasVclRoot.CmdClause, data)
772779
aliasVclConditionRoot := aliasvclcondition.NewRootCommand(aliasVclRoot.CmdClause, data)
@@ -1206,12 +1213,6 @@ func Define( // nolint:revive // function-length
12061213
profileSwitch,
12071214
profileToken,
12081215
profileUpdate,
1209-
rateLimitCmdRoot,
1210-
rateLimitCreate,
1211-
rateLimitDelete,
1212-
rateLimitDescribe,
1213-
rateLimitList,
1214-
rateLimitUpdate,
12151216
resourcelinkCmdRoot,
12161217
resourcelinkCreate,
12171218
resourcelinkDelete,
@@ -1306,6 +1307,12 @@ func Define( // nolint:revive // function-length
13061307
serviceimageoptimizerdefaultsCmdRoot,
13071308
serviceimageoptimizerdefaultsGet,
13081309
serviceimageoptimizerdefaultsUpdate,
1310+
serviceratelimitCmdRoot,
1311+
serviceratelimitCreate,
1312+
serviceratelimitDelete,
1313+
serviceratelimitDescribe,
1314+
serviceratelimitList,
1315+
serviceratelimitUpdate,
13091316
serviceVersionActivate,
13101317
serviceVersionClone,
13111318
serviceVersionCmdRoot,
@@ -1404,6 +1411,11 @@ func Define( // nolint:revive // function-length
14041411
aliasACLEntryDescribe,
14051412
aliasACLEntryList,
14061413
aliasACLEntryUpdate,
1414+
aliasRateLimitCreate,
1415+
aliasRateLimitDelete,
1416+
aliasRateLimitDescribe,
1417+
aliasRateLimitList,
1418+
aliasRateLimitUpdate,
14071419
aliasVclDescribe,
14081420
aliasVclConditionCreate,
14091421
aliasVclConditionDelete,

0 commit comments

Comments
 (0)