Skip to content

Commit e0bc0f5

Browse files
CDTOOL-1254 convert dictionary to service dictionary (#1630)
### Change summary Convert the `dictionary` to `service dictionary` and add alias for deprecated `dictionary` command 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? ### Changes to Core Features: * [x] Have you written new tests for your core changes, as applicable? * [x] Have you successfully run tests with your changes locally?
1 parent fbf0bb5 commit e0bc0f5

File tree

18 files changed

+215
-20
lines changed

18 files changed

+215
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- feat(version): If the latest version is at least one major version higher than the current version, provide links to the release notes for the major version(s) so the user can review them before upgrading. ([#1623](https://github.com/fastly/cli/pull/1623))
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))
23+
- 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))
2324

2425
### Bug fixes:
2526

pkg/app/run_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ config
6666
config-store
6767
config-store-entry
6868
dashboard
69-
dictionary
7069
dictionary-entry
7170
domain
7271
install
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package dictionary
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/dictionary"
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 dictionary 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 dictionary
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/dictionary"
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 dictionary 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 dictionary
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/dictionary"
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 dictionary 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 dictionary contains deprecated aliases for the 'service dictionary' commands.
2+
package dictionary
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package dictionary
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/dictionary"
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 dictionary 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 dictionary
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 = "dictionary"
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 FastlyService Dictionaries").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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package dictionary
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/dictionary"
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+
text.Deprecated(out, "Use the 'service dictionary update' command instead.")
28+
return c.UpdateCommand.Exec(in, out)
29+
}

pkg/commands/commands.go

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
aliasaclentry "github.com/fastly/cli/pkg/commands/alias/aclentry"
99
aliasalerts "github.com/fastly/cli/pkg/commands/alias/alerts"
1010
aliasbackend "github.com/fastly/cli/pkg/commands/alias/backend"
11+
aliasdictionary "github.com/fastly/cli/pkg/commands/alias/dictionary"
1112
aliashealthcheck "github.com/fastly/cli/pkg/commands/alias/healthcheck"
1213
aliasimageoptimizerdefaults "github.com/fastly/cli/pkg/commands/alias/imageoptimizerdefaults"
1314
aliaspurge "github.com/fastly/cli/pkg/commands/alias/purge"
@@ -24,7 +25,6 @@ import (
2425
"github.com/fastly/cli/pkg/commands/configstoreentry"
2526
"github.com/fastly/cli/pkg/commands/dashboard"
2627
dashboardItem "github.com/fastly/cli/pkg/commands/dashboard/item"
27-
"github.com/fastly/cli/pkg/commands/dictionary"
2828
"github.com/fastly/cli/pkg/commands/dictionaryentry"
2929
"github.com/fastly/cli/pkg/commands/domain"
3030
"github.com/fastly/cli/pkg/commands/install"
@@ -102,6 +102,7 @@ import (
102102
serviceaclentry "github.com/fastly/cli/pkg/commands/service/aclentry"
103103
servicealert "github.com/fastly/cli/pkg/commands/service/alert"
104104
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
105+
servicedictionary "github.com/fastly/cli/pkg/commands/service/dictionary"
105106
servicedomain "github.com/fastly/cli/pkg/commands/service/domain"
106107
servicehealthcheck "github.com/fastly/cli/pkg/commands/service/healthcheck"
107108
serviceimageoptimizerdefaults "github.com/fastly/cli/pkg/commands/service/imageoptimizerdefaults"
@@ -196,18 +197,12 @@ func Define( // nolint:revive // function-length
196197
dashboardItemDescribe := dashboardItem.NewDescribeCommand(dashboardItemCmdRoot.CmdClause, data)
197198
dashboardItemUpdate := dashboardItem.NewUpdateCommand(dashboardItemCmdRoot.CmdClause, data)
198199
dashboardItemDelete := dashboardItem.NewDeleteCommand(dashboardItemCmdRoot.CmdClause, data)
199-
dictionaryCmdRoot := dictionary.NewRootCommand(app, data)
200-
dictionaryCreate := dictionary.NewCreateCommand(dictionaryCmdRoot.CmdClause, data)
201-
dictionaryDelete := dictionary.NewDeleteCommand(dictionaryCmdRoot.CmdClause, data)
202-
dictionaryDescribe := dictionary.NewDescribeCommand(dictionaryCmdRoot.CmdClause, data)
203200
dictionaryEntryCmdRoot := dictionaryentry.NewRootCommand(app, data)
204201
dictionaryEntryCreate := dictionaryentry.NewCreateCommand(dictionaryEntryCmdRoot.CmdClause, data)
205202
dictionaryEntryDelete := dictionaryentry.NewDeleteCommand(dictionaryEntryCmdRoot.CmdClause, data)
206203
dictionaryEntryDescribe := dictionaryentry.NewDescribeCommand(dictionaryEntryCmdRoot.CmdClause, data)
207204
dictionaryEntryList := dictionaryentry.NewListCommand(dictionaryEntryCmdRoot.CmdClause, data)
208205
dictionaryEntryUpdate := dictionaryentry.NewUpdateCommand(dictionaryEntryCmdRoot.CmdClause, data)
209-
dictionaryList := dictionary.NewListCommand(dictionaryCmdRoot.CmdClause, data)
210-
dictionaryUpdate := dictionary.NewUpdateCommand(dictionaryCmdRoot.CmdClause, data)
211206
domainCmdRoot := domain.NewRootCommand(app, data)
212207
domainCreate := domain.NewCreateCommand(domainCmdRoot.CmdClause, data)
213208
domainDelete := domain.NewDeleteCommand(domainCmdRoot.CmdClause, data)
@@ -619,6 +614,12 @@ func Define( // nolint:revive // function-length
619614
serviceauthDescribe := serviceauth.NewDescribeCommand(serviceauthCmdRoot.CmdClause, data)
620615
serviceauthList := serviceauth.NewListCommand(serviceauthCmdRoot.CmdClause, data)
621616
serviceauthUpdate := serviceauth.NewUpdateCommand(serviceauthCmdRoot.CmdClause, data)
617+
servicedictionaryCmdRoot := servicedictionary.NewRootCommand(serviceCmdRoot.CmdClause, data)
618+
servicedictionaryCreate := servicedictionary.NewCreateCommand(servicedictionaryCmdRoot.CmdClause, data)
619+
servicedictionaryDelete := servicedictionary.NewDeleteCommand(servicedictionaryCmdRoot.CmdClause, data)
620+
servicedictionaryDescribe := servicedictionary.NewDescribeCommand(servicedictionaryCmdRoot.CmdClause, data)
621+
servicedictionaryList := servicedictionary.NewListCommand(servicedictionaryCmdRoot.CmdClause, data)
622+
servicedictionaryUpdate := servicedictionary.NewUpdateCommand(servicedictionaryCmdRoot.CmdClause, data)
622623
servicevclCmdRoot := servicevcl.NewRootCommand(serviceCmdRoot.CmdClause, data)
623624
servicevclDescribe := servicevcl.NewDescribeCommand(servicevclCmdRoot.CmdClause, data)
624625
servicevclConditionCmdRoot := servicevclcondition.NewRootCommand(servicevclCmdRoot.CmdClause, data)
@@ -731,6 +732,12 @@ func Define( // nolint:revive // function-length
731732
aliasBackendDescribe := aliasbackend.NewDescribeCommand(aliasBackendRoot.CmdClause, data)
732733
aliasBackendList := aliasbackend.NewListCommand(aliasBackendRoot.CmdClause, data)
733734
aliasBackendUpdate := aliasbackend.NewUpdateCommand(aliasBackendRoot.CmdClause, data)
735+
aliasDictionaryRoot := aliasdictionary.NewRootCommand(app, data)
736+
aliasDictionaryCreate := aliasdictionary.NewCreateCommand(aliasDictionaryRoot.CmdClause, data)
737+
aliasDictionaryDelete := aliasdictionary.NewDeleteCommand(aliasDictionaryRoot.CmdClause, data)
738+
aliasDictionaryDescribe := aliasdictionary.NewDescribeCommand(aliasDictionaryRoot.CmdClause, data)
739+
aliasDictionaryList := aliasdictionary.NewListCommand(aliasDictionaryRoot.CmdClause, data)
740+
aliasDictionaryUpdate := aliasdictionary.NewUpdateCommand(aliasDictionaryRoot.CmdClause, data)
734741
aliasHealthcheckRoot := aliashealthcheck.NewRootCommand(app, data)
735742
aliasHealthcheckCreate := aliashealthcheck.NewCreateCommand(aliasHealthcheckRoot.CmdClause, data)
736743
aliasHealthcheckDelete := aliashealthcheck.NewDeleteCommand(aliasHealthcheckRoot.CmdClause, data)
@@ -841,18 +848,12 @@ func Define( // nolint:revive // function-length
841848
dashboardItemDescribe,
842849
dashboardItemUpdate,
843850
dashboardItemDelete,
844-
dictionaryCmdRoot,
845-
dictionaryCreate,
846-
dictionaryDelete,
847-
dictionaryDescribe,
848851
dictionaryEntryCmdRoot,
849852
dictionaryEntryCreate,
850853
dictionaryEntryDelete,
851854
dictionaryEntryDescribe,
852855
dictionaryEntryList,
853856
dictionaryEntryUpdate,
854-
dictionaryList,
855-
dictionaryUpdate,
856857
domainCmdRoot,
857858
domainCreate,
858859
domainDelete,
@@ -1257,6 +1258,12 @@ func Define( // nolint:revive // function-length
12571258
serviceauthDescribe,
12581259
serviceauthList,
12591260
serviceauthUpdate,
1261+
servicedictionaryCmdRoot,
1262+
servicedictionaryCreate,
1263+
servicedictionaryDelete,
1264+
servicedictionaryDescribe,
1265+
servicedictionaryList,
1266+
servicedictionaryUpdate,
12601267
servicevclCmdRoot,
12611268
servicevclDescribe,
12621269
servicevclConditionCmdRoot,
@@ -1367,6 +1374,11 @@ func Define( // nolint:revive // function-length
13671374
aliasBackendDescribe,
13681375
aliasBackendList,
13691376
aliasBackendUpdate,
1377+
aliasDictionaryCreate,
1378+
aliasDictionaryDelete,
1379+
aliasDictionaryDescribe,
1380+
aliasDictionaryList,
1381+
aliasDictionaryUpdate,
13701382
aliasHealthcheckCreate,
13711383
aliasHealthcheckDelete,
13721384
aliasHealthcheckDescribe,

0 commit comments

Comments
 (0)