Skip to content

Commit 9c1f02f

Browse files
CDTOOL-1264: Introduce 'service version ...' commands and 'service-version ...' aliases. (#1614)
### Change summary This PR adds the 'service version ...' commands as a replacement for the 'service-version ...' commands. The 'service-version ...' commands are still available as aliases, but will issue a deprecation warning when used (except when JSON output is requested). This involved a number of changes: 1. The existing 'pkg/commands/serviceversion' package content was moved to 'pkg/commands/service/version', and modified to work as expected in that location. 2. An alias package was added in 'pkg/commands/alias/serviceversion'. This alias package uses `struct` embedding to avoid duplicating any of the code from the `pkg/commands/service/version' package. The alias commands are 'unlisted' and issue a deprecation warning when used. 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: * [X] Does your submission pass tests? ### User Impact <!-- What is the user impact of this change? --> New deprecation warning for the `service-version ...` commands. Co-authored-by: Anthony Gomez <anthony.gomez@fastly.com>
1 parent e3bd798 commit 9c1f02f

25 files changed

Lines changed: 313 additions & 25 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- feat(compute/deploy): added the `--no-default-domain` flag to allow for the skipping of automatic domain creation when deploying a Compute service([#1610](https://github.com/fastly/cli/pull/1610))
1313
- refactor(argparser/flags.go): add flag conversion utilities for converting string flags to bools and checking ascending and desecnding flags ([#1611](https://github.com/fastly/cli/pull/1611))
1414
- feat(commands/service/purge): Add 'service purge' command as replacement for 'purge', with an unlisted and deprecated alias of 'purge'. ([#1612](https://github.com/fastly/cli/pull/1612))
15+
- feat(commands/service/version): Add 'service version ...' commands as replacements for 'service-version ...', with unlisted and deprecated aliases of 'service-version ...'. ([#1614](https://github.com/fastly/cli/pull/1614))
1516

1617
### Bug fixes:
1718

pkg/app/run_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ secret-store
9292
secret-store-entry
9393
service
9494
service-auth
95-
service-version
9695
stats
9796
tls-config
9897
tls-custom
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package serviceversion
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/version"
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+
// ActivateCommand wraps the ActivateCommand from the newcmd package.
14+
type ActivateCommand struct {
15+
*newcmd.ActivateCommand
16+
}
17+
18+
// NewActivateCommand returns a usable command registered under the parent.
19+
func NewActivateCommand(parent argparser.Registerer, g *global.Data) *ActivateCommand {
20+
c := ActivateCommand{newcmd.NewActivateCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *ActivateCommand) Exec(in io.Reader, out io.Writer) error {
27+
text.Deprecated(out, "Use the 'service version activate' command instead.")
28+
return c.ActivateCommand.Exec(in, out)
29+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package serviceversion
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/version"
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+
// CloneCommand wraps the CloneCommand from the newcmd package.
14+
type CloneCommand struct {
15+
*newcmd.CloneCommand
16+
}
17+
18+
// NewCloneCommand returns a usable command registered under the parent.
19+
func NewCloneCommand(parent argparser.Registerer, g *global.Data) *CloneCommand {
20+
c := CloneCommand{newcmd.NewCloneCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *CloneCommand) Exec(in io.Reader, out io.Writer) error {
27+
if !c.JSONOutput.Enabled {
28+
text.Deprecated(out, "Use the 'service version clone' command instead.")
29+
}
30+
return c.CloneCommand.Exec(in, out)
31+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package serviceversion
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/version"
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+
// DeactivateCommand wraps the DeactivateCommand from the newcmd package.
14+
type DeactivateCommand struct {
15+
*newcmd.DeactivateCommand
16+
}
17+
18+
// NewDeactivateCommand returns a usable command registered under the parent.
19+
func NewDeactivateCommand(parent argparser.Registerer, g *global.Data) *DeactivateCommand {
20+
c := DeactivateCommand{newcmd.NewDeactivateCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *DeactivateCommand) Exec(in io.Reader, out io.Writer) error {
27+
text.Deprecated(out, "Use the 'service version deactivate' command instead.")
28+
return c.DeactivateCommand.Exec(in, out)
29+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package serviceversion contains the 'service-version' aliases for the 'service version' commands.
2+
package serviceversion
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package serviceversion
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/version"
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 version list' command instead.")
29+
}
30+
return c.ListCommand.Exec(in, out)
31+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package serviceversion
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/version"
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+
// LockCommand wraps the LockCommand from the newcmd package.
14+
type LockCommand struct {
15+
*newcmd.LockCommand
16+
}
17+
18+
// NewLockCommand returns a usable command registered under the parent.
19+
func NewLockCommand(parent argparser.Registerer, g *global.Data) *LockCommand {
20+
c := LockCommand{newcmd.NewLockCommand(parent, g)}
21+
c.CmdClause.Hidden()
22+
return &c
23+
}
24+
25+
// Exec implements the command interface.
26+
func (c *LockCommand) Exec(in io.Reader, out io.Writer) error {
27+
text.Deprecated(out, "Use the 'service version lock' command instead.")
28+
return c.LockCommand.Exec(in, out)
29+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const CommandName = "service-version"
2121
func NewRootCommand(parent argparser.Registerer, g *global.Data) *RootCommand {
2222
var c RootCommand
2323
c.Globals = g
24-
c.CmdClause = parent.Command(CommandName, "Manipulate Fastly service versions")
24+
c.CmdClause = parent.Command(CommandName, "Manipulate Fastly service versions").Hidden()
2525
return &c
2626
}
2727

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

0 commit comments

Comments
 (0)