Skip to content

Commit e63cb49

Browse files
committed
command restructure
1 parent 34586f7 commit e63cb49

13 files changed

Lines changed: 25 additions & 23 deletions

File tree

pkg/commands/commands.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ import (
5656
"github.com/fastly/cli/pkg/commands/logging/syslog"
5757
"github.com/fastly/cli/pkg/commands/logtail"
5858
"github.com/fastly/cli/pkg/commands/ngwaf"
59-
"github.com/fastly/cli/pkg/commands/ngwaf/redaction"
60-
"github.com/fastly/cli/pkg/commands/ngwaf/virtualpatch"
6159
"github.com/fastly/cli/pkg/commands/ngwaf/workspace"
60+
"github.com/fastly/cli/pkg/commands/ngwaf/workspace/redaction"
61+
"github.com/fastly/cli/pkg/commands/ngwaf/workspace/virtualpatch"
6262
"github.com/fastly/cli/pkg/commands/objectstorage"
6363
"github.com/fastly/cli/pkg/commands/objectstorage/accesskeys"
6464
"github.com/fastly/cli/pkg/commands/pop"
@@ -398,22 +398,22 @@ func Define( // nolint:revive // function-length
398398
loggingSyslogList := syslog.NewListCommand(loggingSyslogCmdRoot.CmdClause, data)
399399
loggingSyslogUpdate := syslog.NewUpdateCommand(loggingSyslogCmdRoot.CmdClause, data)
400400
ngwafRoot := ngwaf.NewRootCommand(app, data)
401-
ngwafRedactionRoot := redaction.NewRootCommand(ngwafRoot.CmdClause, data)
401+
ngwafWorkspacesRoot := workspace.NewRootCommand(ngwafRoot.CmdClause, data)
402+
ngwafWorkspacesCreate := workspace.NewCreateCommand(ngwafWorkspacesRoot.CmdClause, data)
403+
ngwafWorkspacesDelete := workspace.NewDeleteCommand(ngwafWorkspacesRoot.CmdClause, data)
404+
ngwafWorkspacesGet := workspace.NewGetCommand(ngwafWorkspacesRoot.CmdClause, data)
405+
ngwafWorkspacesList := workspace.NewListCommand(ngwafWorkspacesRoot.CmdClause, data)
406+
ngwafWorkspacesUpdate := workspace.NewUpdateCommand(ngwafWorkspacesRoot.CmdClause, data)
407+
ngwafRedactionRoot := redaction.NewRootCommand(ngwafWorkspacesRoot.CmdClause, data)
402408
ngwafRedactionCreate := redaction.NewCreateCommand(ngwafRedactionRoot.CmdClause, data)
403409
ngwafRedactionDelete := redaction.NewDeleteCommand(ngwafRedactionRoot.CmdClause, data)
404410
ngwafRedactionList := redaction.NewListCommand(ngwafRedactionRoot.CmdClause, data)
405411
ngwafRedactionRetrieve := redaction.NewRetrieveCommand(ngwafRedactionRoot.CmdClause, data)
406412
ngwafRedactionUpdate := redaction.NewUpdateCommand(ngwafRedactionRoot.CmdClause, data)
407-
ngwafVirtualpatchRoot := virtualpatch.NewRootCommand(ngwafRoot.CmdClause, data)
413+
ngwafVirtualpatchRoot := virtualpatch.NewRootCommand(ngwafWorkspacesRoot.CmdClause, data)
408414
ngwafVirtualpatchList := virtualpatch.NewListCommand(ngwafVirtualpatchRoot.CmdClause, data)
409415
ngwafVirtualpatchUpdate := virtualpatch.NewUpdateCommand(ngwafVirtualpatchRoot.CmdClause, data)
410416
ngwafVirtualpatchRetrieve := virtualpatch.NewRetrieveCommand(ngwafVirtualpatchRoot.CmdClause, data)
411-
ngwafWorkspacesRoot := workspace.NewRootCommand(ngwafRoot.CmdClause, data)
412-
ngwafWorkspacesCreate := workspace.NewCreateCommand(ngwafWorkspacesRoot.CmdClause, data)
413-
ngwafWorkspacesDelete := workspace.NewDeleteCommand(ngwafWorkspacesRoot.CmdClause, data)
414-
ngwafWorkspacesGet := workspace.NewGetCommand(ngwafWorkspacesRoot.CmdClause, data)
415-
ngwafWorkspacesList := workspace.NewListCommand(ngwafWorkspacesRoot.CmdClause, data)
416-
ngwafWorkspacesUpdate := workspace.NewUpdateCommand(ngwafWorkspacesRoot.CmdClause, data)
417417
objectStorageRoot := objectstorage.NewRootCommand(app, data)
418418
objectStorageAccesskeysRoot := accesskeys.NewRootCommand(objectStorageRoot.CmdClause, data)
419419
objectStorageAccesskeysCreate := accesskeys.NewCreateCommand(objectStorageAccesskeysRoot.CmdClause, data)

pkg/commands/ngwaf/redaction/create.go renamed to pkg/commands/ngwaf/workspace/redaction/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman
3131
Globals: g,
3232
},
3333
}
34-
c.CmdClause = parent.Command("create", "Create a redaction")
34+
c.CmdClause = parent.Command("create", "Create a redaction").Alias("add")
3535

3636
// Required.
3737
c.CmdClause.Flag("field", "The name of the field that should be redacted.").Required().StringVar(&c.field)
File renamed without changes.
File renamed without changes.

pkg/commands/ngwaf/redaction/redaction_test.go renamed to pkg/commands/ngwaf/workspace/redaction/redaction_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99
"testing"
1010

1111
root "github.com/fastly/cli/pkg/commands/ngwaf"
12-
sub "github.com/fastly/cli/pkg/commands/ngwaf/redaction"
12+
workspace "github.com/fastly/cli/pkg/commands/ngwaf/workspace"
13+
sub "github.com/fastly/cli/pkg/commands/ngwaf/workspace/redaction"
1314
fstfmt "github.com/fastly/cli/pkg/fmt"
1415
"github.com/fastly/cli/pkg/testutil"
1516
"github.com/fastly/go-fastly/v12/fastly/ngwaf/v1/workspaces/redactions"
@@ -89,7 +90,7 @@ func TestRedactionCreate(t *testing.T) {
8990
},
9091
}
9192

92-
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "create"}, scenarios)
93+
testutil.RunCLIScenarios(t, []string{root.CommandName, workspace.CommandName, sub.CommandName, "create"}, scenarios)
9394
}
9495

9596
func TestRedactionDelete(t *testing.T) {
@@ -151,7 +152,7 @@ func TestRedactionDelete(t *testing.T) {
151152
},
152153
}
153154

154-
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "delete"}, scenarios)
155+
testutil.RunCLIScenarios(t, []string{root.CommandName, workspace.CommandName, sub.CommandName, "delete"}, scenarios)
155156
}
156157

157158
func TestRedactionRetrieve(t *testing.T) {
@@ -215,7 +216,7 @@ func TestRedactionRetrieve(t *testing.T) {
215216
},
216217
}
217218

218-
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "retrieve"}, scenarios)
219+
testutil.RunCLIScenarios(t, []string{root.CommandName, workspace.CommandName, sub.CommandName, "retrieve"}, scenarios)
219220
}
220221

221222
func TestRedactionList(t *testing.T) {
@@ -303,7 +304,7 @@ func TestRedactionList(t *testing.T) {
303304
},
304305
}
305306

306-
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "list"}, scenarios)
307+
testutil.RunCLIScenarios(t, []string{root.CommandName, workspace.CommandName, sub.CommandName, "list"}, scenarios)
307308
}
308309

309310
func TestRedactionUpdate(t *testing.T) {
@@ -354,7 +355,7 @@ func TestRedactionUpdate(t *testing.T) {
354355
WantOutput: fstfmt.EncodeJSON(redaction),
355356
},
356357
}
357-
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "update"}, scenarios)
358+
testutil.RunCLIScenarios(t, []string{root.CommandName, workspace.CommandName, sub.CommandName, "update"}, scenarios)
358359
}
359360

360361
var listRedactionString = strings.TrimSpace(`

pkg/commands/ngwaf/redaction/retrieve.go renamed to pkg/commands/ngwaf/workspace/redaction/retrieve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewRetrieveCommand(parent argparser.Registerer, g *global.Data) *GetCommand
3232
},
3333
}
3434

35-
c.CmdClause = parent.Command("retrieve", "Retrieve a redaction")
35+
c.CmdClause = parent.Command("retrieve", "Retrieve a redaction").Alias("get")
3636

3737
// Required.
3838
c.CmdClause.Flag("redaction-id", "Redaction ID").Required().StringVar(&c.redactionID)
File renamed without changes.
File renamed without changes.
File renamed without changes.

pkg/commands/ngwaf/virtualpatch/retrieve.go renamed to pkg/commands/ngwaf/workspace/virtualpatch/retrieve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewRetrieveCommand(parent argparser.Registerer, g *global.Data) *GetCommand
3232
},
3333
}
3434

35-
c.CmdClause = parent.Command("retrieve", "Retrieve a vitual patch")
35+
c.CmdClause = parent.Command("retrieve", "Retrieve a vitual patch").Alias("get")
3636

3737
// Required.
3838
c.CmdClause.Flag("virtual-patch-id", "Virtual Patch ID").Required().StringVar(&c.virtualpatchID)

0 commit comments

Comments
 (0)