Skip to content

Commit 541957d

Browse files
feat(commands/service/alert): convert alerts to service alert (#1626)
BREAKING CHANGE ### Change summary Convert `alerts` to `service alert` 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? ### Changes to Core Features: * [x] Have you written new tests for your core changes, as applicable? * [x] Have you successfully run tests with your changes locally?
1 parent 90809dc commit 541957d

25 files changed

Lines changed: 267 additions & 30 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- feat(service/backend): moved the `backend` command under the `service` command, with an unlisted and deprecated alias of `backend` ([#1621](https://github.com/fastly/cli/pull/1621))
1919
- feat(service/backend): moved the `acl` and `aclentry` commands under the `service` command, with a unlisted and deprecated aliases of `acl` and `aclentry` ([#1621](https://github.com/fastly/cli/pull/1624))
2020
- 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))
21+
- 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))
2122

2223
### Bug fixes:
2324

pkg/app/run_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ complete -F _fastly_bash_autocomplete fastly
6060
Args: "--completion-bash",
6161
WantOutput: `help
6262
sso
63-
alerts
6463
auth-token
6564
compute
6665
config

pkg/commands/alias/acl/describe.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func NewDescribeCommand(parent argparser.Registerer, g *global.Data) *DescribeCo
2424

2525
// Exec implements the command interface.
2626
func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error {
27-
text.Deprecated(out, "Use the 'service acl describe' command instead.")
27+
if !c.JSONOutput.Enabled {
28+
text.Deprecated(out, "Use the 'service acl describe' command instead.")
29+
}
2830
return c.DescribeCommand.Exec(in, out)
2931
}

pkg/commands/alias/acl/list.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func NewListCommand(parent argparser.Registerer, g *global.Data) *ListCommand {
2424

2525
// Exec implements the command interface.
2626
func (c *ListCommand) Exec(in io.Reader, out io.Writer) error {
27-
text.Deprecated(out, "Use the 'service acl list' command instead.")
27+
if !c.JSONOutput.Enabled {
28+
text.Deprecated(out, "Use the 'service acl list' command instead.")
29+
}
2830
return c.ListCommand.Exec(in, out)
2931
}

pkg/commands/alias/aclentry/describe.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func NewDescribeCommand(parent argparser.Registerer, g *global.Data) *DescribeCo
2424

2525
// Exec implements the command interface.
2626
func (c *DescribeCommand) Exec(in io.Reader, out io.Writer) error {
27-
text.Deprecated(out, "Use the 'service aclentry describe' command instead.")
27+
if !c.JSONOutput.Enabled {
28+
text.Deprecated(out, "Use the 'service aclentry describe' command instead.")
29+
}
2830
return c.DescribeCommand.Exec(in, out)
2931
}

pkg/commands/alias/aclentry/list.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func NewListCommand(parent argparser.Registerer, g *global.Data) *ListCommand {
2424

2525
// Exec implements the command interface.
2626
func (c *ListCommand) Exec(in io.Reader, out io.Writer) error {
27-
text.Deprecated(out, "Use the 'service aclentry list' command instead.")
27+
if !c.JSONOutput.Enabled {
28+
text.Deprecated(out, "Use the 'service aclentry list' command instead.")
29+
}
2830
return c.ListCommand.Exec(in, out)
2931
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package alerts
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/alert"
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 alert 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 alerts
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/alert"
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 alert 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 alerts
2+
3+
import (
4+
"io"
5+
6+
newcmd "github.com/fastly/cli/pkg/commands/service/alert"
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 alert describe' command instead.")
29+
}
30+
return c.DescribeCommand.Exec(in, out)
31+
}

pkg/commands/alias/alerts/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package alerts contains deprecated aliases for the 'service alert' commands.
2+
package alerts

0 commit comments

Comments
 (0)