Skip to content

Commit e78fbd7

Browse files
committed
moved backend under service & created alias'
1 parent aae4e12 commit e78fbd7

17 files changed

Lines changed: 202 additions & 15 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package backend
2+
3+
import (
4+
"io"
5+
6+
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
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 servicebackend package.
14+
type CreateCommand struct {
15+
*servicebackend.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{servicebackend.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 backend 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 backend
2+
3+
import (
4+
"io"
5+
6+
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
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 servicebackend package.
14+
type DeleteCommand struct {
15+
*servicebackend.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{servicebackend.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 backend delete' command instead.")
28+
return c.DeleteCommand.Exec(in, out)
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package backend
2+
3+
import (
4+
"io"
5+
6+
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
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 servicebackend package.
14+
type DescribeCommand struct {
15+
*servicebackend.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{servicebackend.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+
text.Deprecated(out, "Use the 'service backend describe' command instead.")
28+
return c.DescribeCommand.Exec(in, out)
29+
}

pkg/commands/alias/backend/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package backend contains the 'backend' alias for the 'service backend' command.
2+
package backend

pkg/commands/alias/backend/list.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package backend
2+
3+
import (
4+
"io"
5+
6+
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
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 servicebackend package.
14+
type ListCommand struct {
15+
*servicebackend.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{servicebackend.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+
text.Deprecated(out, "Use the 'service backend list' command instead.")
28+
return c.ListCommand.Exec(in, out)
29+
}

pkg/commands/alias/backend/root.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package backend
2+
3+
import (
4+
"io"
5+
6+
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
7+
8+
"github.com/fastly/cli/pkg/argparser"
9+
"github.com/fastly/cli/pkg/global"
10+
)
11+
12+
// RootCommand wraps the RootCommand from the servicebackend package.
13+
type RootCommand struct {
14+
*servicebackend.RootCommand
15+
}
16+
17+
// NewRootCommand returns a usable command registered under the parent.
18+
func NewRootCommand(parent argparser.Registerer, g *global.Data) *RootCommand {
19+
c := RootCommand{servicebackend.NewRootCommand(parent, g)}
20+
c.CmdClause.Hidden()
21+
return &c
22+
}
23+
24+
// Exec implements the command interface.
25+
func (c *RootCommand) Exec(in io.Reader, out io.Writer) error {
26+
return c.RootCommand.Exec(in, out)
27+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package backend
2+
3+
import (
4+
"io"
5+
6+
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
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 servicebackend package.
14+
type UpdateCommand struct {
15+
*servicebackend.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{servicebackend.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 backend update' command instead.")
28+
return c.UpdateCommand.Exec(in, out)
29+
}

pkg/commands/commands.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/fastly/cli/pkg/commands/acl"
88
"github.com/fastly/cli/pkg/commands/aclentry"
99
"github.com/fastly/cli/pkg/commands/alerts"
10+
aliasbackend "github.com/fastly/cli/pkg/commands/alias/backend"
1011
aliashealthcheck "github.com/fastly/cli/pkg/commands/alias/healthcheck"
1112
aliaspurge "github.com/fastly/cli/pkg/commands/alias/purge"
1213
aliasvcl "github.com/fastly/cli/pkg/commands/alias/vcl"
@@ -15,7 +16,6 @@ import (
1516
aliasvclsnippet "github.com/fastly/cli/pkg/commands/alias/vcl/snippet"
1617
aliasserviceversion "github.com/fastly/cli/pkg/commands/alias/serviceversion"
1718
"github.com/fastly/cli/pkg/commands/authtoken"
18-
"github.com/fastly/cli/pkg/commands/backend"
1919
"github.com/fastly/cli/pkg/commands/compute"
2020
"github.com/fastly/cli/pkg/commands/compute/computeacl"
2121
"github.com/fastly/cli/pkg/commands/config"
@@ -98,6 +98,7 @@ import (
9898
"github.com/fastly/cli/pkg/commands/secretstore"
9999
"github.com/fastly/cli/pkg/commands/secretstoreentry"
100100
"github.com/fastly/cli/pkg/commands/service"
101+
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
101102
servicedomain "github.com/fastly/cli/pkg/commands/service/domain"
102103
servicehealthcheck "github.com/fastly/cli/pkg/commands/service/healthcheck"
103104
servicepurge "github.com/fastly/cli/pkg/commands/service/purge"
@@ -166,12 +167,12 @@ func Define( // nolint:revive // function-length
166167
authtokenDelete := authtoken.NewDeleteCommand(authtokenCmdRoot.CmdClause, data)
167168
authtokenDescribe := authtoken.NewDescribeCommand(authtokenCmdRoot.CmdClause, data)
168169
authtokenList := authtoken.NewListCommand(authtokenCmdRoot.CmdClause, data)
169-
backendCmdRoot := backend.NewRootCommand(app, data)
170-
backendCreate := backend.NewCreateCommand(backendCmdRoot.CmdClause, data)
171-
backendDelete := backend.NewDeleteCommand(backendCmdRoot.CmdClause, data)
172-
backendDescribe := backend.NewDescribeCommand(backendCmdRoot.CmdClause, data)
173-
backendList := backend.NewListCommand(backendCmdRoot.CmdClause, data)
174-
backendUpdate := backend.NewUpdateCommand(backendCmdRoot.CmdClause, data)
170+
backendCmdRoot := aliasbackend.NewRootCommand(app, data)
171+
backendCreate := aliasbackend.NewCreateCommand(backendCmdRoot.CmdClause, data)
172+
backendDelete := aliasbackend.NewDeleteCommand(backendCmdRoot.CmdClause, data)
173+
backendDescribe := aliasbackend.NewDescribeCommand(backendCmdRoot.CmdClause, data)
174+
backendList := aliasbackend.NewListCommand(backendCmdRoot.CmdClause, data)
175+
backendUpdate := aliasbackend.NewUpdateCommand(backendCmdRoot.CmdClause, data)
175176
computeCmdRoot := compute.NewRootCommand(app, data)
176177
computeACLCmdRoot := computeacl.NewRootCommand(computeCmdRoot.CmdClause, data)
177178
computeACLCreate := computeacl.NewCreateCommand(computeACLCmdRoot.CmdClause, data)
@@ -665,6 +666,12 @@ func Define( // nolint:revive // function-length
665666
servicedomainList := servicedomain.NewListCommand(servicedomainCmdRoot.CmdClause, data)
666667
servicedomainUpdate := servicedomain.NewUpdateCommand(servicedomainCmdRoot.CmdClause, data)
667668
servicedomainValidate := servicedomain.NewValidateCommand(servicedomainCmdRoot.CmdClause, data)
669+
servicebackendCmdRoot := servicebackend.NewRootCommand(serviceCmdRoot.CmdClause, data)
670+
servicebackendCreate := servicebackend.NewCreateCommand(servicebackendCmdRoot.CmdClause, data)
671+
servicebackendDelete := servicebackend.NewDeleteCommand(servicebackendCmdRoot.CmdClause, data)
672+
servicebackendDescribe := servicebackend.NewDescribeCommand(servicebackendCmdRoot.CmdClause, data)
673+
servicebackendList := servicebackend.NewListCommand(servicebackendCmdRoot.CmdClause, data)
674+
servicebackendUpdate := servicebackend.NewUpdateCommand(servicebackendCmdRoot.CmdClause, data)
668675
servicehealthcheckCmdRoot := servicehealthcheck.NewRootCommand(serviceCmdRoot.CmdClause, data)
669676
servicehealthcheckCreate := servicehealthcheck.NewCreateCommand(servicehealthcheckCmdRoot.CmdClause, data)
670677
servicehealthcheckDelete := servicehealthcheck.NewDeleteCommand(servicehealthcheckCmdRoot.CmdClause, data)
@@ -782,7 +789,6 @@ func Define( // nolint:revive // function-length
782789
authtokenDelete,
783790
authtokenDescribe,
784791
authtokenList,
785-
backendCmdRoot,
786792
backendCreate,
787793
backendDelete,
788794
backendDescribe,
@@ -1265,6 +1271,12 @@ func Define( // nolint:revive // function-length
12651271
servicedomainList,
12661272
servicedomainUpdate,
12671273
servicedomainValidate,
1274+
servicebackendCmdRoot,
1275+
servicebackendCreate,
1276+
servicebackendDelete,
1277+
servicebackendDescribe,
1278+
servicebackendList,
1279+
servicebackendUpdate,
12681280
servicehealthcheckCmdRoot,
12691281
servicehealthcheckCreate,
12701282
servicehealthcheckDelete,

pkg/commands/compute/setup/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/fastly/go-fastly/v12/fastly"
1111

1212
"github.com/fastly/cli/pkg/api"
13-
"github.com/fastly/cli/pkg/commands/backend"
13+
"github.com/fastly/cli/pkg/commands/service/backend"
1414
"github.com/fastly/cli/pkg/errors"
1515
"github.com/fastly/cli/pkg/manifest"
1616
"github.com/fastly/cli/pkg/text"

pkg/commands/backend/backend_test.go renamed to pkg/commands/service/backend/backend_test.go

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

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

13-
root "github.com/fastly/cli/pkg/commands/backend"
13+
root "github.com/fastly/cli/pkg/commands/service"
14+
sub "github.com/fastly/cli/pkg/commands/service/backend"
1415
fsterr "github.com/fastly/cli/pkg/errors"
1516
"github.com/fastly/cli/pkg/mock"
1617
"github.com/fastly/cli/pkg/testutil"
@@ -206,7 +207,7 @@ func TestBackendCreate(t *testing.T) {
206207
WantError: "'prefer-ipv6' flag must be one of the following [true, false]",
207208
},
208209
}
209-
testutil.RunCLIScenarios(t, []string{root.CommandName, "create"}, scenarios)
210+
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "create"}, scenarios)
210211
}
211212

212213
func TestBackendList(t *testing.T) {
@@ -276,7 +277,7 @@ func TestBackendList(t *testing.T) {
276277
WantError: errTest.Error(),
277278
},
278279
}
279-
testutil.RunCLIScenarios(t, []string{root.CommandName, "list"}, scenarios)
280+
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "list"}, scenarios)
280281
}
281282

282283
func TestBackendDescribe(t *testing.T) {
@@ -302,7 +303,7 @@ func TestBackendDescribe(t *testing.T) {
302303
WantOutput: describeBackendOutput,
303304
},
304305
}
305-
testutil.RunCLIScenarios(t, []string{root.CommandName, "describe"}, scenarios)
306+
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "describe"}, scenarios)
306307
}
307308

308309
func TestBackendUpdate(t *testing.T) {
@@ -394,7 +395,7 @@ func TestBackendUpdate(t *testing.T) {
394395
WantError: "'prefer-ipv6' flag must be one of the following [true, false]",
395396
},
396397
}
397-
testutil.RunCLIScenarios(t, []string{root.CommandName, "update"}, scenarios)
398+
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "update"}, scenarios)
398399
}
399400

400401
func TestBackendDelete(t *testing.T) {
@@ -422,7 +423,7 @@ func TestBackendDelete(t *testing.T) {
422423
WantOutput: "Deleted backend www.test.com (service 123 version 4)",
423424
},
424425
}
425-
testutil.RunCLIScenarios(t, []string{root.CommandName, "delete"}, scenarios)
426+
testutil.RunCLIScenarios(t, []string{root.CommandName, sub.CommandName, "delete"}, scenarios)
426427
}
427428

428429
var errTest = errors.New("fixture error")

0 commit comments

Comments
 (0)