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 @@ -20,6 +20,7 @@
- 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))
- 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))

### 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 @@ -66,7 +66,6 @@ config
config-store
config-store-entry
dashboard
dictionary
dictionary-entry
domain
install
Expand Down
29 changes: 29 additions & 0 deletions pkg/commands/alias/dictionary/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dictionary

import (
"io"

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

"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 dictionary create' command instead.")
return c.CreateCommand.Exec(in, out)
}
29 changes: 29 additions & 0 deletions pkg/commands/alias/dictionary/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dictionary

import (
"io"

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

"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 dictionary delete' command instead.")
return c.DeleteCommand.Exec(in, out)
}
31 changes: 31 additions & 0 deletions pkg/commands/alias/dictionary/describe.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dictionary

import (
"io"

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

"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 dictionary describe' command instead.")
}
return c.DescribeCommand.Exec(in, out)
}
2 changes: 2 additions & 0 deletions pkg/commands/alias/dictionary/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package dictionary contains deprecated aliases for the 'service dictionary' commands.
package dictionary
31 changes: 31 additions & 0 deletions pkg/commands/alias/dictionary/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dictionary

import (
"io"

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

"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 dictionary list' command instead.")
}
return c.ListCommand.Exec(in, out)
}
31 changes: 31 additions & 0 deletions pkg/commands/alias/dictionary/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dictionary

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 = "dictionary"

// 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 FastlyService Dictionaries").Hidden()
return &c
}

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

import (
"io"

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

"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 {
text.Deprecated(out, "Use the 'service dictionary 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 @@ -8,6 +8,7 @@ import (
aliasaclentry "github.com/fastly/cli/pkg/commands/alias/aclentry"
aliasalerts "github.com/fastly/cli/pkg/commands/alias/alerts"
aliasbackend "github.com/fastly/cli/pkg/commands/alias/backend"
aliasdictionary "github.com/fastly/cli/pkg/commands/alias/dictionary"
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"
Expand All @@ -24,7 +25,6 @@ import (
"github.com/fastly/cli/pkg/commands/configstoreentry"
"github.com/fastly/cli/pkg/commands/dashboard"
dashboardItem "github.com/fastly/cli/pkg/commands/dashboard/item"
"github.com/fastly/cli/pkg/commands/dictionary"
"github.com/fastly/cli/pkg/commands/dictionaryentry"
"github.com/fastly/cli/pkg/commands/domain"
"github.com/fastly/cli/pkg/commands/install"
Expand Down Expand Up @@ -102,6 +102,7 @@ import (
serviceaclentry "github.com/fastly/cli/pkg/commands/service/aclentry"
servicealert "github.com/fastly/cli/pkg/commands/service/alert"
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
servicedictionary "github.com/fastly/cli/pkg/commands/service/dictionary"
servicedomain "github.com/fastly/cli/pkg/commands/service/domain"
servicehealthcheck "github.com/fastly/cli/pkg/commands/service/healthcheck"
serviceimageoptimizerdefaults "github.com/fastly/cli/pkg/commands/service/imageoptimizerdefaults"
Expand Down Expand Up @@ -196,18 +197,12 @@ func Define( // nolint:revive // function-length
dashboardItemDescribe := dashboardItem.NewDescribeCommand(dashboardItemCmdRoot.CmdClause, data)
dashboardItemUpdate := dashboardItem.NewUpdateCommand(dashboardItemCmdRoot.CmdClause, data)
dashboardItemDelete := dashboardItem.NewDeleteCommand(dashboardItemCmdRoot.CmdClause, data)
dictionaryCmdRoot := dictionary.NewRootCommand(app, data)
dictionaryCreate := dictionary.NewCreateCommand(dictionaryCmdRoot.CmdClause, data)
dictionaryDelete := dictionary.NewDeleteCommand(dictionaryCmdRoot.CmdClause, data)
dictionaryDescribe := dictionary.NewDescribeCommand(dictionaryCmdRoot.CmdClause, data)
dictionaryEntryCmdRoot := dictionaryentry.NewRootCommand(app, data)
dictionaryEntryCreate := dictionaryentry.NewCreateCommand(dictionaryEntryCmdRoot.CmdClause, data)
dictionaryEntryDelete := dictionaryentry.NewDeleteCommand(dictionaryEntryCmdRoot.CmdClause, data)
dictionaryEntryDescribe := dictionaryentry.NewDescribeCommand(dictionaryEntryCmdRoot.CmdClause, data)
dictionaryEntryList := dictionaryentry.NewListCommand(dictionaryEntryCmdRoot.CmdClause, data)
dictionaryEntryUpdate := dictionaryentry.NewUpdateCommand(dictionaryEntryCmdRoot.CmdClause, data)
dictionaryList := dictionary.NewListCommand(dictionaryCmdRoot.CmdClause, data)
dictionaryUpdate := dictionary.NewUpdateCommand(dictionaryCmdRoot.CmdClause, data)
domainCmdRoot := domain.NewRootCommand(app, data)
domainCreate := domain.NewCreateCommand(domainCmdRoot.CmdClause, data)
domainDelete := domain.NewDeleteCommand(domainCmdRoot.CmdClause, data)
Expand Down Expand Up @@ -619,6 +614,12 @@ func Define( // nolint:revive // function-length
serviceauthDescribe := serviceauth.NewDescribeCommand(serviceauthCmdRoot.CmdClause, data)
serviceauthList := serviceauth.NewListCommand(serviceauthCmdRoot.CmdClause, data)
serviceauthUpdate := serviceauth.NewUpdateCommand(serviceauthCmdRoot.CmdClause, data)
servicedictionaryCmdRoot := servicedictionary.NewRootCommand(serviceCmdRoot.CmdClause, data)
servicedictionaryCreate := servicedictionary.NewCreateCommand(servicedictionaryCmdRoot.CmdClause, data)
servicedictionaryDelete := servicedictionary.NewDeleteCommand(servicedictionaryCmdRoot.CmdClause, data)
servicedictionaryDescribe := servicedictionary.NewDescribeCommand(servicedictionaryCmdRoot.CmdClause, data)
servicedictionaryList := servicedictionary.NewListCommand(servicedictionaryCmdRoot.CmdClause, data)
servicedictionaryUpdate := servicedictionary.NewUpdateCommand(servicedictionaryCmdRoot.CmdClause, data)
servicevclCmdRoot := servicevcl.NewRootCommand(serviceCmdRoot.CmdClause, data)
servicevclDescribe := servicevcl.NewDescribeCommand(servicevclCmdRoot.CmdClause, data)
servicevclConditionCmdRoot := servicevclcondition.NewRootCommand(servicevclCmdRoot.CmdClause, data)
Expand Down Expand Up @@ -731,6 +732,12 @@ func Define( // nolint:revive // function-length
aliasBackendDescribe := aliasbackend.NewDescribeCommand(aliasBackendRoot.CmdClause, data)
aliasBackendList := aliasbackend.NewListCommand(aliasBackendRoot.CmdClause, data)
aliasBackendUpdate := aliasbackend.NewUpdateCommand(aliasBackendRoot.CmdClause, data)
aliasDictionaryRoot := aliasdictionary.NewRootCommand(app, data)
aliasDictionaryCreate := aliasdictionary.NewCreateCommand(aliasDictionaryRoot.CmdClause, data)
aliasDictionaryDelete := aliasdictionary.NewDeleteCommand(aliasDictionaryRoot.CmdClause, data)
aliasDictionaryDescribe := aliasdictionary.NewDescribeCommand(aliasDictionaryRoot.CmdClause, data)
aliasDictionaryList := aliasdictionary.NewListCommand(aliasDictionaryRoot.CmdClause, data)
aliasDictionaryUpdate := aliasdictionary.NewUpdateCommand(aliasDictionaryRoot.CmdClause, data)
aliasHealthcheckRoot := aliashealthcheck.NewRootCommand(app, data)
aliasHealthcheckCreate := aliashealthcheck.NewCreateCommand(aliasHealthcheckRoot.CmdClause, data)
aliasHealthcheckDelete := aliashealthcheck.NewDeleteCommand(aliasHealthcheckRoot.CmdClause, data)
Expand Down Expand Up @@ -841,18 +848,12 @@ func Define( // nolint:revive // function-length
dashboardItemDescribe,
dashboardItemUpdate,
dashboardItemDelete,
dictionaryCmdRoot,
dictionaryCreate,
dictionaryDelete,
dictionaryDescribe,
dictionaryEntryCmdRoot,
dictionaryEntryCreate,
dictionaryEntryDelete,
dictionaryEntryDescribe,
dictionaryEntryList,
dictionaryEntryUpdate,
dictionaryList,
dictionaryUpdate,
domainCmdRoot,
domainCreate,
domainDelete,
Expand Down Expand Up @@ -1257,6 +1258,12 @@ func Define( // nolint:revive // function-length
serviceauthDescribe,
serviceauthList,
serviceauthUpdate,
servicedictionaryCmdRoot,
servicedictionaryCreate,
servicedictionaryDelete,
servicedictionaryDescribe,
servicedictionaryList,
servicedictionaryUpdate,
servicevclCmdRoot,
servicevclDescribe,
servicevclConditionCmdRoot,
Expand Down Expand Up @@ -1367,6 +1374,11 @@ func Define( // nolint:revive // function-length
aliasBackendDescribe,
aliasBackendList,
aliasBackendUpdate,
aliasDictionaryCreate,
aliasDictionaryDelete,
aliasDictionaryDescribe,
aliasDictionaryList,
aliasDictionaryUpdate,
aliasHealthcheckCreate,
aliasHealthcheckDelete,
aliasHealthcheckDescribe,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (

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

root "github.com/fastly/cli/pkg/commands/dictionary"
root "github.com/fastly/cli/pkg/commands/service"
sub "github.com/fastly/cli/pkg/commands/service/dictionary"
"github.com/fastly/cli/pkg/mock"
"github.com/fastly/cli/pkg/testutil"
)
Expand Down Expand Up @@ -46,7 +47,7 @@ func TestDictionaryDescribe(t *testing.T) {
WantOutput: describeDictionaryOutputVerbose,
},
}
testutil.RunCLIScenarios(t, []string{root.CommandName, "describe"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "describe"}, scenarios)
}

func TestDictionaryCreate(t *testing.T) {
Expand Down Expand Up @@ -91,7 +92,7 @@ func TestDictionaryCreate(t *testing.T) {
WantError: "Duplicate record",
},
}
testutil.RunCLIScenarios(t, []string{root.CommandName, "create"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "create"}, scenarios)
}

func TestDeleteDictionary(t *testing.T) {
Expand Down Expand Up @@ -119,7 +120,7 @@ func TestDeleteDictionary(t *testing.T) {
WantError: errTest.Error(),
},
}
testutil.RunCLIScenarios(t, []string{root.CommandName, "delete"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "delete"}, scenarios)
}

func TestListDictionary(t *testing.T) {
Expand All @@ -145,7 +146,7 @@ func TestListDictionary(t *testing.T) {
WantOutput: listDictionariesOutput,
},
}
testutil.RunCLIScenarios(t, []string{root.CommandName, "list"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "list"}, scenarios)
}

func TestUpdateDictionary(t *testing.T) {
Expand Down Expand Up @@ -216,7 +217,7 @@ func TestUpdateDictionary(t *testing.T) {
WantError: errTest.Error(),
},
}
testutil.RunCLIScenarios(t, []string{root.CommandName, "update"}, scenarios)
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "update"}, scenarios)
}

func describeDictionaryOK(_ context.Context, i *fastly.GetDictionaryInput) (*fastly.Dictionary, error) {
Expand Down