Skip to content

Commit a730749

Browse files
committed
refactor: drop transitional gflashduty alias and GF-prefixed names
The dual-client migration is complete; there is one client (go-flashduty). Import it un-aliased as `flashduty`; rename newGFClient/runGFCommand/ RunContext.GFClient to newClient/runCommand/Client. Pure rename, no behavior change.
1 parent 633b7ab commit a730749

32 files changed

Lines changed: 424 additions & 424 deletions

internal/cli/alert.go

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strconv"
77
"strings"
88

9-
gflashduty "github.com/flashcatcloud/go-flashduty"
9+
"github.com/flashcatcloud/go-flashduty"
1010
"github.com/spf13/cobra"
1111

1212
"github.com/flashcatcloud/flashduty-cli/internal/output"
@@ -35,7 +35,7 @@ func newAlertListCmd() *cobra.Command {
3535
Use: "list",
3636
Short: "List alerts",
3737
RunE: func(cmd *cobra.Command, args []string) error {
38-
return runGFCommand(cmd, args, func(ctx *RunContext) error {
38+
return runCommand(cmd, args, func(ctx *RunContext) error {
3939
if active && recovered {
4040
return fmt.Errorf("--active and --recovered are mutually exclusive")
4141
}
@@ -49,7 +49,7 @@ func newAlertListCmd() *cobra.Command {
4949
return fmt.Errorf("invalid --until: %w", err)
5050
}
5151

52-
req := &gflashduty.AlertListRequest{
52+
req := &flashduty.AlertListRequest{
5353
StartTime: startTime,
5454
EndTime: endTime,
5555
AlertSeverity: severity,
@@ -60,13 +60,13 @@ func newAlertListCmd() *cobra.Command {
6060
// Preserve legacy semantics: --active sends is_active=true,
6161
// --recovered sends is_active=false, neither omits the filter.
6262
if active {
63-
req.IsActive = gflashduty.Bool(true)
63+
req.IsActive = flashduty.Bool(true)
6464
} else if recovered {
65-
req.IsActive = gflashduty.Bool(false)
65+
req.IsActive = flashduty.Bool(false)
6666
}
6767

6868
if muted {
69-
req.EverMuted = gflashduty.Bool(true)
69+
req.EverMuted = flashduty.Bool(true)
7070
}
7171

7272
if channel != "" {
@@ -77,19 +77,19 @@ func newAlertListCmd() *cobra.Command {
7777
req.ChannelIDs = channelIDs
7878
}
7979

80-
result, _, err := ctx.GFClient.Alerts.ReadList(cmdContext(ctx.Cmd), req)
80+
result, _, err := ctx.Client.Alerts.ReadList(cmdContext(ctx.Cmd), req)
8181
if err != nil {
8282
return err
8383
}
8484

8585
cols := []output.Column{
86-
{Header: "ID", Field: func(v any) string { return v.(gflashduty.AlertItem).AlertID }},
87-
{Header: "TITLE", MaxWidth: 50, Field: func(v any) string { return v.(gflashduty.AlertItem).Title }},
88-
{Header: "SEVERITY", Field: func(v any) string { return v.(gflashduty.AlertItem).AlertSeverity }},
89-
{Header: "STATUS", Field: func(v any) string { return v.(gflashduty.AlertItem).AlertStatus }},
90-
{Header: "EVENTS", Field: func(v any) string { return fmt.Sprintf("%d", v.(gflashduty.AlertItem).EventCnt) }},
91-
{Header: "CHANNEL", Field: func(v any) string { return v.(gflashduty.AlertItem).ChannelName }},
92-
{Header: "STARTED", Field: func(v any) string { return output.FormatTime(v.(gflashduty.AlertItem).StartTime) }},
86+
{Header: "ID", Field: func(v any) string { return v.(flashduty.AlertItem).AlertID }},
87+
{Header: "TITLE", MaxWidth: 50, Field: func(v any) string { return v.(flashduty.AlertItem).Title }},
88+
{Header: "SEVERITY", Field: func(v any) string { return v.(flashduty.AlertItem).AlertSeverity }},
89+
{Header: "STATUS", Field: func(v any) string { return v.(flashduty.AlertItem).AlertStatus }},
90+
{Header: "EVENTS", Field: func(v any) string { return fmt.Sprintf("%d", v.(flashduty.AlertItem).EventCnt) }},
91+
{Header: "CHANNEL", Field: func(v any) string { return v.(flashduty.AlertItem).ChannelName }},
92+
{Header: "STARTED", Field: func(v any) string { return output.FormatTime(v.(flashduty.AlertItem).StartTime) }},
9393
}
9494

9595
return ctx.PrintList(result.Items, cols, len(result.Items), page, int(result.Total))
@@ -116,8 +116,8 @@ func newAlertGetCmd() *cobra.Command {
116116
Short: "Get alert detail",
117117
Args: requireArgs("alert_id"),
118118
RunE: func(cmd *cobra.Command, args []string) error {
119-
return runGFCommand(cmd, args, func(ctx *RunContext) error {
120-
result, _, err := ctx.GFClient.Alerts.ReadInfo(cmdContext(ctx.Cmd), &gflashduty.AlertInfoRequest{
119+
return runCommand(cmd, args, func(ctx *RunContext) error {
120+
result, _, err := ctx.Client.Alerts.ReadInfo(cmdContext(ctx.Cmd), &flashduty.AlertInfoRequest{
121121
AlertID: ctx.Args[0],
122122
})
123123
if err != nil {
@@ -135,7 +135,7 @@ func newAlertGetCmd() *cobra.Command {
135135
}
136136
}
137137

138-
func printAlertDetail(w io.Writer, a *gflashduty.AlertItem) {
138+
func printAlertDetail(w io.Writer, a *flashduty.AlertItem) {
139139
if a == nil {
140140
return
141141
}
@@ -178,8 +178,8 @@ func newAlertEventsCmd() *cobra.Command {
178178
Short: "List alert events",
179179
Args: requireArgs("alert_id"),
180180
RunE: func(cmd *cobra.Command, args []string) error {
181-
return runGFCommand(cmd, args, func(ctx *RunContext) error {
182-
result, _, err := ctx.GFClient.Alerts.ReadEventList(cmdContext(ctx.Cmd), &gflashduty.AlertEventListRequest{
181+
return runCommand(cmd, args, func(ctx *RunContext) error {
182+
result, _, err := ctx.Client.Alerts.ReadEventList(cmdContext(ctx.Cmd), &flashduty.AlertEventListRequest{
183183
AlertID: ctx.Args[0],
184184
})
185185
if err != nil {
@@ -192,11 +192,11 @@ func newAlertEventsCmd() *cobra.Command {
192192
}
193193

194194
cols := []output.Column{
195-
{Header: "EVENT_ID", Field: func(v any) string { return v.(gflashduty.AlertEventItem).EventID }},
196-
{Header: "SEVERITY", Field: func(v any) string { return v.(gflashduty.AlertEventItem).EventSeverity }},
197-
{Header: "STATUS", Field: func(v any) string { return v.(gflashduty.AlertEventItem).EventStatus }},
198-
{Header: "TIME", Field: func(v any) string { return output.FormatTime(v.(gflashduty.AlertEventItem).EventTime) }},
199-
{Header: "TITLE", MaxWidth: 50, Field: func(v any) string { return v.(gflashduty.AlertEventItem).Title }},
195+
{Header: "EVENT_ID", Field: func(v any) string { return v.(flashduty.AlertEventItem).EventID }},
196+
{Header: "SEVERITY", Field: func(v any) string { return v.(flashduty.AlertEventItem).EventSeverity }},
197+
{Header: "STATUS", Field: func(v any) string { return v.(flashduty.AlertEventItem).EventStatus }},
198+
{Header: "TIME", Field: func(v any) string { return output.FormatTime(v.(flashduty.AlertEventItem).EventTime) }},
199+
{Header: "TITLE", MaxWidth: 50, Field: func(v any) string { return v.(flashduty.AlertEventItem).Title }},
200200
}
201201

202202
return ctx.PrintTotal(result.Items, cols, len(result.Items))
@@ -213,12 +213,12 @@ func newAlertTimelineCmd() *cobra.Command {
213213
Short: "View alert timeline",
214214
Args: requireArgs("alert_id"),
215215
RunE: func(cmd *cobra.Command, args []string) error {
216-
return runGFCommand(cmd, args, func(ctx *RunContext) error {
217-
req := &gflashduty.AlertFeedRequest{AlertID: ctx.Args[0]}
216+
return runCommand(cmd, args, func(ctx *RunContext) error {
217+
req := &flashduty.AlertFeedRequest{AlertID: ctx.Args[0]}
218218
req.Limit = limit
219219
req.Page = page
220220

221-
result, _, err := ctx.GFClient.Alerts.ReadFeed(cmdContext(ctx.Cmd), req)
221+
result, _, err := ctx.Client.Alerts.ReadFeed(cmdContext(ctx.Cmd), req)
222222
if err != nil {
223223
return err
224224
}
@@ -236,10 +236,10 @@ func newAlertTimelineCmd() *cobra.Command {
236236
nameByID := resolveAlertFeedOperators(ctx, result.Items)
237237

238238
cols := []output.Column{
239-
{Header: "TIME", Field: func(v any) string { return output.FormatTime(v.(gflashduty.FeedItem).CreatedAt) }},
240-
{Header: "TYPE", Field: func(v any) string { return string(v.(gflashduty.FeedItem).Type) }},
239+
{Header: "TIME", Field: func(v any) string { return output.FormatTime(v.(flashduty.FeedItem).CreatedAt) }},
240+
{Header: "TYPE", Field: func(v any) string { return string(v.(flashduty.FeedItem).Type) }},
241241
{Header: "OPERATOR", Field: func(v any) string {
242-
it := v.(gflashduty.FeedItem)
242+
it := v.(flashduty.FeedItem)
243243
if it.CreatorID == 0 {
244244
return "system"
245245
}
@@ -249,7 +249,7 @@ func newAlertTimelineCmd() *cobra.Command {
249249
return strconv.FormatInt(it.CreatorID, 10)
250250
}},
251251
{Header: "DETAIL", MaxWidth: 80, Field: func(v any) string {
252-
d := v.(gflashduty.FeedItem).Detail
252+
d := v.(flashduty.FeedItem).Detail
253253
if d == nil {
254254
return "-"
255255
}
@@ -272,7 +272,7 @@ func newAlertTimelineCmd() *cobra.Command {
272272
// alert-feed items to display names via /person/infos, replicating the
273273
// operator-name enrichment the legacy SDK did server-side. Best-effort: a
274274
// lookup failure yields a nil map and callers fall back to the numeric ID.
275-
func resolveAlertFeedOperators(rc *RunContext, items []gflashduty.FeedItem) map[int64]string {
275+
func resolveAlertFeedOperators(rc *RunContext, items []flashduty.FeedItem) map[int64]string {
276276
seen := make(map[int64]struct{}, len(items))
277277
ids := make([]uint64, 0, len(items))
278278
for _, it := range items {
@@ -288,7 +288,7 @@ func resolveAlertFeedOperators(rc *RunContext, items []gflashduty.FeedItem) map[
288288
if len(ids) == 0 {
289289
return nil
290290
}
291-
resp, _, err := rc.GFClient.Members.PersonInfos(cmdContext(rc.Cmd), &gflashduty.PersonInfosRequest{PersonIDs: ids})
291+
resp, _, err := rc.Client.Members.PersonInfos(cmdContext(rc.Cmd), &flashduty.PersonInfosRequest{PersonIDs: ids})
292292
if err != nil || resp == nil {
293293
return nil
294294
}
@@ -307,8 +307,8 @@ func newAlertMergeCmd() *cobra.Command {
307307
Short: "Merge alerts into an incident",
308308
Args: requireArgs("alert_id"),
309309
RunE: func(cmd *cobra.Command, args []string) error {
310-
return runGFCommand(cmd, args, func(ctx *RunContext) error {
311-
if _, err := ctx.GFClient.Alerts.WriteMerge(cmdContext(ctx.Cmd), &gflashduty.AlertMergeRequest{
310+
return runCommand(cmd, args, func(ctx *RunContext) error {
311+
if _, err := ctx.Client.Alerts.WriteMerge(cmdContext(ctx.Cmd), &flashduty.AlertMergeRequest{
312312
AlertIDs: ctx.Args,
313313
IncidentID: incidentID,
314314
Comment: comment,

internal/cli/alert_event.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7-
gflashduty "github.com/flashcatcloud/go-flashduty"
7+
"github.com/flashcatcloud/go-flashduty"
88
"github.com/spf13/cobra"
99

1010
"github.com/flashcatcloud/flashduty-cli/internal/output"
@@ -28,7 +28,7 @@ func newAlertEventListCmd() *cobra.Command {
2828
Use: "list",
2929
Short: "List alert events globally",
3030
RunE: func(cmd *cobra.Command, args []string) error {
31-
return runGFCommand(cmd, args, func(ctx *RunContext) error {
31+
return runCommand(cmd, args, func(ctx *RunContext) error {
3232
startTime, err := timeutil.Parse(since)
3333
if err != nil {
3434
return fmt.Errorf("invalid --since: %w", err)
@@ -38,7 +38,7 @@ func newAlertEventListCmd() *cobra.Command {
3838
return fmt.Errorf("invalid --until: %w", err)
3939
}
4040

41-
input := &gflashduty.AlertEventGlobalListRequest{
41+
input := &flashduty.AlertEventGlobalListRequest{
4242
StartTime: startTime,
4343
EndTime: endTime,
4444
}
@@ -62,18 +62,18 @@ func newAlertEventListCmd() *cobra.Command {
6262
input.IntegrationTypes = parseStringSlice(integrationType)
6363
}
6464

65-
result, _, err := ctx.GFClient.Alerts.EventReadList(cmdContext(ctx.Cmd), input)
65+
result, _, err := ctx.Client.Alerts.EventReadList(cmdContext(ctx.Cmd), input)
6666
if err != nil {
6767
return err
6868
}
6969

7070
cols := []output.Column{
71-
{Header: "EVENT_ID", Field: func(v any) string { return v.(gflashduty.AlertEventItem).EventID }},
72-
{Header: "ALERT_ID", Field: func(v any) string { return v.(gflashduty.AlertEventItem).AlertID }},
73-
{Header: "SEVERITY", Field: func(v any) string { return v.(gflashduty.AlertEventItem).EventSeverity }},
74-
{Header: "STATUS", Field: func(v any) string { return v.(gflashduty.AlertEventItem).EventStatus }},
75-
{Header: "TIME", Field: func(v any) string { return output.FormatTime(v.(gflashduty.AlertEventItem).EventTime) }},
76-
{Header: "TITLE", MaxWidth: 50, Field: func(v any) string { return v.(gflashduty.AlertEventItem).Title }},
71+
{Header: "EVENT_ID", Field: func(v any) string { return v.(flashduty.AlertEventItem).EventID }},
72+
{Header: "ALERT_ID", Field: func(v any) string { return v.(flashduty.AlertEventItem).AlertID }},
73+
{Header: "SEVERITY", Field: func(v any) string { return v.(flashduty.AlertEventItem).EventSeverity }},
74+
{Header: "STATUS", Field: func(v any) string { return v.(flashduty.AlertEventItem).EventStatus }},
75+
{Header: "TIME", Field: func(v any) string { return output.FormatTime(v.(flashduty.AlertEventItem).EventTime) }},
76+
{Header: "TITLE", MaxWidth: 50, Field: func(v any) string { return v.(flashduty.AlertEventItem).Title }},
7777
}
7878

7979
return ctx.PrintList(result.Items, cols, len(result.Items), page, int(result.Total))

internal/cli/audit.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package cli
33
import (
44
"fmt"
55

6-
gflashduty "github.com/flashcatcloud/go-flashduty"
6+
"github.com/flashcatcloud/go-flashduty"
77
"github.com/spf13/cobra"
88

99
"github.com/flashcatcloud/flashduty-cli/internal/output"
@@ -28,7 +28,7 @@ func newAuditSearchCmd() *cobra.Command {
2828
Use: "search",
2929
Short: "Search audit logs",
3030
RunE: func(cmd *cobra.Command, args []string) error {
31-
return runGFCommand(cmd, args, func(ctx *RunContext) error {
31+
return runCommand(cmd, args, func(ctx *RunContext) error {
3232
startTime, err := timeutil.Parse(since)
3333
if err != nil {
3434
return fmt.Errorf("invalid --since: %w", err)
@@ -38,7 +38,7 @@ func newAuditSearchCmd() *cobra.Command {
3838
return fmt.Errorf("invalid --until: %w", err)
3939
}
4040

41-
input := &gflashduty.AuditSearchRequest{
41+
input := &flashduty.AuditSearchRequest{
4242
StartTime: startTime,
4343
EndTime: endTime,
4444
Limit: int64(limit),
@@ -49,21 +49,21 @@ func newAuditSearchCmd() *cobra.Command {
4949
}
5050

5151
var (
52-
result *gflashduty.AuditSearchResponse
52+
result *flashduty.AuditSearchResponse
5353
cursor string
5454
)
5555
for currentPage := 1; currentPage <= page; currentPage++ {
5656
input.SearchAfterCtx = cursor
57-
result, _, err = ctx.GFClient.AuditLogs.Search(cmdContext(ctx.Cmd), input)
57+
result, _, err = ctx.Client.AuditLogs.Search(cmdContext(ctx.Cmd), input)
5858
if err != nil {
5959
return err
6060
}
6161
if currentPage == page {
6262
break
6363
}
6464
if result.SearchAfterCtx == "" {
65-
result = &gflashduty.AuditSearchResponse{
66-
Docs: []gflashduty.AuditLog{},
65+
result = &flashduty.AuditSearchResponse{
66+
Docs: []flashduty.AuditLog{},
6767
Total: result.Total,
6868
}
6969
break
@@ -73,24 +73,24 @@ func newAuditSearchCmd() *cobra.Command {
7373

7474
cols := []output.Column{
7575
{Header: "TIME", Field: func(v any) string {
76-
return output.FormatTime(v.(gflashduty.AuditLog).CreatedAt)
76+
return output.FormatTime(v.(flashduty.AuditLog).CreatedAt)
7777
}},
7878
{Header: "PERSON", MaxWidth: 20, Field: func(v any) string {
79-
r := v.(gflashduty.AuditLog)
79+
r := v.(flashduty.AuditLog)
8080
if r.MemberName != "" {
8181
return r.MemberName
8282
}
8383
return fmt.Sprintf("%d", r.MemberID)
8484
}},
8585
{Header: "OPERATION", MaxWidth: 30, Field: func(v any) string {
86-
r := v.(gflashduty.AuditLog)
86+
r := v.(flashduty.AuditLog)
8787
if r.OperationName != "" {
8888
return r.OperationName
8989
}
9090
return r.Operation
9191
}},
9292
{Header: "DETAIL", MaxWidth: 50, Field: func(v any) string {
93-
r := v.(gflashduty.AuditLog)
93+
r := v.(flashduty.AuditLog)
9494
if r.Body != "" {
9595
return r.Body
9696
}

internal/cli/change.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package cli
33
import (
44
"fmt"
55

6-
gflashduty "github.com/flashcatcloud/go-flashduty"
6+
"github.com/flashcatcloud/go-flashduty"
77
"github.com/spf13/cobra"
88

99
"github.com/flashcatcloud/flashduty-cli/internal/output"
@@ -28,7 +28,7 @@ func newChangeListCmd() *cobra.Command {
2828
Use: "list",
2929
Short: "List changes",
3030
RunE: func(cmd *cobra.Command, args []string) error {
31-
return runGFCommand(cmd, args, func(ctx *RunContext) error {
31+
return runCommand(cmd, args, func(ctx *RunContext) error {
3232
startTime, err := timeutil.Parse(since)
3333
if err != nil {
3434
return fmt.Errorf("invalid --since: %w", err)
@@ -51,7 +51,7 @@ func newChangeListCmd() *cobra.Command {
5151
reqPage = 1
5252
}
5353

54-
input := &gflashduty.ListChangeRequest{
54+
input := &flashduty.ListChangeRequest{
5555
StartTime: startTime,
5656
EndTime: endTime,
5757
}
@@ -66,17 +66,17 @@ func newChangeListCmd() *cobra.Command {
6666
input.ChannelIDs = channelIDs
6767
}
6868

69-
result, _, err := ctx.GFClient.Changes.List(cmdContext(ctx.Cmd), input)
69+
result, _, err := ctx.Client.Changes.List(cmdContext(ctx.Cmd), input)
7070
if err != nil {
7171
return err
7272
}
7373

7474
cols := []output.Column{
75-
{Header: "ID", Field: func(v any) string { return v.(gflashduty.ChangeItem).ChangeID }},
76-
{Header: "TITLE", MaxWidth: 50, Field: func(v any) string { return v.(gflashduty.ChangeItem).Title }},
77-
{Header: "STATUS", Field: func(v any) string { return v.(gflashduty.ChangeItem).ChangeStatus }},
78-
{Header: "CHANNEL", Field: func(v any) string { return v.(gflashduty.ChangeItem).ChannelName }},
79-
{Header: "TIME", Field: func(v any) string { return output.FormatTime(v.(gflashduty.ChangeItem).StartTime) }},
75+
{Header: "ID", Field: func(v any) string { return v.(flashduty.ChangeItem).ChangeID }},
76+
{Header: "TITLE", MaxWidth: 50, Field: func(v any) string { return v.(flashduty.ChangeItem).Title }},
77+
{Header: "STATUS", Field: func(v any) string { return v.(flashduty.ChangeItem).ChangeStatus }},
78+
{Header: "CHANNEL", Field: func(v any) string { return v.(flashduty.ChangeItem).ChannelName }},
79+
{Header: "TIME", Field: func(v any) string { return output.FormatTime(v.(flashduty.ChangeItem).StartTime) }},
8080
}
8181

8282
return ctx.PrintList(result.Items, cols, len(result.Items), page, int(result.Total))

0 commit comments

Comments
 (0)