Skip to content

Commit 4391dac

Browse files
feat(cmd/service/auth): move service-auth into the service/auth folder and rename to auth as well as create deprecation alias for service-auth
BREAKING CHANGE:
1 parent c1bcb3f commit 4391dac

20 files changed

Lines changed: 228 additions & 35 deletions

File tree

pkg/app/run_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ profile
8181
secret-store
8282
secret-store-entry
8383
service
84-
service-auth
8584
stats
8685
tls-config
8786
tls-custom
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package serviceauth
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/auth"
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 auth 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 serviceauth
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/auth"
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 auth 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 serviceauth
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/auth"
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 auth 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 serviceauth contains deprecated aliases for the 'service auth' commands.
2+
package serviceauth
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package serviceauth
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/auth"
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 auth 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 serviceauth
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 = "serviceauth"
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 Fastly Service Authentication").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 serviceauth
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/auth"
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 auth update' command instead.")
28+
return c.UpdateCommand.Exec(in, out)
29+
}

pkg/commands/commands.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
aliaspurge "github.com/fastly/cli/pkg/commands/alias/purge"
1616
aliasratelimit "github.com/fastly/cli/pkg/commands/alias/ratelimit"
1717
aliasresourcelink "github.com/fastly/cli/pkg/commands/alias/resourcelink"
18+
aliasserviceauth "github.com/fastly/cli/pkg/commands/alias/serviceauth"
1819
aliasserviceversion "github.com/fastly/cli/pkg/commands/alias/serviceversion"
1920
aliasvcl "github.com/fastly/cli/pkg/commands/alias/vcl"
2021
aliasvclcondition "github.com/fastly/cli/pkg/commands/alias/vcl/condition"
@@ -101,6 +102,7 @@ import (
101102
serviceacl "github.com/fastly/cli/pkg/commands/service/acl"
102103
serviceaclentry "github.com/fastly/cli/pkg/commands/service/aclentry"
103104
servicealert "github.com/fastly/cli/pkg/commands/service/alert"
105+
serviceauth "github.com/fastly/cli/pkg/commands/service/auth"
104106
servicebackend "github.com/fastly/cli/pkg/commands/service/backend"
105107
servicedictionary "github.com/fastly/cli/pkg/commands/service/dictionary"
106108
servicedictionaryentry "github.com/fastly/cli/pkg/commands/service/dictionaryentry"
@@ -115,7 +117,6 @@ import (
115117
servicevclcustom "github.com/fastly/cli/pkg/commands/service/vcl/custom"
116118
servicevclsnippet "github.com/fastly/cli/pkg/commands/service/vcl/snippet"
117119
serviceversion "github.com/fastly/cli/pkg/commands/service/version"
118-
"github.com/fastly/cli/pkg/commands/serviceauth"
119120
"github.com/fastly/cli/pkg/commands/shellcomplete"
120121
"github.com/fastly/cli/pkg/commands/sso"
121122
"github.com/fastly/cli/pkg/commands/stats"
@@ -593,7 +594,7 @@ func Define( // nolint:revive // function-length
593594
serviceaclentryDescribe := serviceaclentry.NewDescribeCommand(serviceaclentryCmdRoot.CmdClause, data)
594595
serviceaclentryList := serviceaclentry.NewListCommand(serviceaclentryCmdRoot.CmdClause, data)
595596
serviceaclentryUpdate := serviceaclentry.NewUpdateCommand(serviceaclentryCmdRoot.CmdClause, data)
596-
serviceauthCmdRoot := serviceauth.NewRootCommand(app, data)
597+
serviceauthCmdRoot := serviceauth.NewRootCommand(serviceCmdRoot.CmdClause, data)
597598
serviceauthCreate := serviceauth.NewCreateCommand(serviceauthCmdRoot.CmdClause, data)
598599
serviceauthDelete := serviceauth.NewDeleteCommand(serviceauthCmdRoot.CmdClause, data)
599600
serviceauthDescribe := serviceauth.NewDescribeCommand(serviceauthCmdRoot.CmdClause, data)
@@ -788,6 +789,12 @@ func Define( // nolint:revive // function-length
788789
aliasResourceLinkDescribe := aliasresourcelink.NewDescribeCommand(aliasResourceLinkRoot.CmdClause, data)
789790
aliasResourceLinkList := aliasresourcelink.NewListCommand(aliasResourceLinkRoot.CmdClause, data)
790791
aliasResourceLinkUpdate := aliasresourcelink.NewUpdateCommand(aliasResourceLinkRoot.CmdClause, data)
792+
aliasServiceAuthRoot := aliasserviceauth.NewRootCommand(app, data)
793+
aliasServiceAuthCreate := aliasserviceauth.NewCreateCommand(aliasServiceAuthRoot.CmdClause, data)
794+
aliasServiceAuthDelete := aliasserviceauth.NewDeleteCommand(aliasServiceAuthRoot.CmdClause, data)
795+
aliasServiceAuthDescribe := aliasserviceauth.NewDescribeCommand(aliasServiceAuthRoot.CmdClause, data)
796+
aliasServiceAuthList := aliasserviceauth.NewListCommand(aliasServiceAuthRoot.CmdClause, data)
797+
aliasServiceAuthUpdate := aliasserviceauth.NewUpdateCommand(aliasServiceAuthRoot.CmdClause, data)
791798
aliasVclRoot := aliasvcl.NewRootCommand(app, data)
792799
aliasVclDescribe := aliasvcl.NewDescribeCommand(aliasVclRoot.CmdClause, data)
793800
aliasVclConditionRoot := aliasvclcondition.NewRootCommand(aliasVclRoot.CmdClause, data)
@@ -1440,6 +1447,11 @@ func Define( // nolint:revive // function-length
14401447
aliasResourceLinkDescribe,
14411448
aliasResourceLinkList,
14421449
aliasResourceLinkUpdate,
1450+
aliasServiceAuthCreate,
1451+
aliasServiceAuthDelete,
1452+
aliasServiceAuthDescribe,
1453+
aliasServiceAuthList,
1454+
aliasServiceAuthUpdate,
14431455
aliasVclDescribe,
14441456
aliasVclConditionCreate,
14451457
aliasVclConditionDelete,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package serviceauth
1+
package auth
22

33
import (
44
"context"

0 commit comments

Comments
 (0)