Skip to content

Commit deecc61

Browse files
committed
fix(cockpit): remove WaitForAlert and keep only WaitForPreconfiguredAlerts
1 parent 417d470 commit deecc61

File tree

2 files changed

+2
-55
lines changed

2 files changed

+2
-55
lines changed

api/cockpit/v1/cockpit_utils.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,6 @@ const (
1313
defaultTimeout = 5 * time.Minute
1414
)
1515

16-
// WaitForAlertRequest is used by WaitForAlert method.
17-
type WaitForAlertRequest struct {
18-
Region scw.Region
19-
AlertID string
20-
Timeout *time.Duration
21-
RetryInterval *time.Duration
22-
}
23-
24-
// WaitForAlert waits for the alert to be in a "terminal state" before returning.
25-
// This function can be used to wait for an alert to be enabled or disabled.
26-
func (s *RegionalAPI) WaitForAlert(req *WaitForAlertRequest, opts ...scw.RequestOption) (*Alert, error) {
27-
timeout := defaultTimeout
28-
if req.Timeout != nil {
29-
timeout = *req.Timeout
30-
}
31-
retryInterval := defaultRetryInterval
32-
if req.RetryInterval != nil {
33-
retryInterval = *req.RetryInterval
34-
}
35-
36-
terminalStatus := map[AlertStatus]struct{}{
37-
AlertStatusEnabled: {},
38-
AlertStatusDisabled: {},
39-
}
40-
41-
alert, err := async.WaitSync(&async.WaitSyncConfig{
42-
Get: func() (any, bool, error) {
43-
// List all alerts and find the one with matching ID
44-
res, err := s.ListAlerts(&RegionalAPIListAlertsRequest{
45-
Region: req.Region,
46-
}, opts...)
47-
if err != nil {
48-
return nil, false, err
49-
}
50-
51-
// Find the alert by ID
52-
for _, alert := range res.Alerts {
53-
if alert.ID == req.AlertID {
54-
_, isTerminal := terminalStatus[alert.RuleStatus]
55-
return alert, isTerminal, nil
56-
}
57-
}
58-
59-
return nil, false, errors.New("alert not found")
60-
},
61-
Timeout: timeout,
62-
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
63-
})
64-
if err != nil {
65-
return nil, errors.Wrap(err, "waiting for alert failed")
66-
}
67-
return alert.(*Alert), nil
68-
}
69-
7016
// WaitForPreconfiguredAlertsRequest is used by WaitForPreconfiguredAlerts method.
7117
type WaitForPreconfiguredAlertsRequest struct {
7218
Region scw.Region
@@ -159,4 +105,3 @@ func (s *RegionalAPI) WaitForPreconfiguredAlerts(req *WaitForPreconfiguredAlerts
159105
}
160106
return result.([]*Alert), nil
161107
}
162-

api/cockpit/v1/sweepers/sweepers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func SweepGrafanaUser(scwClient *scw.Client) error {
5757
continue
5858
}
5959

60+
//nolint:staticcheck // Deprecated functions are still functional and needed for sweepers
6061
listGrafanaUsers, err := cockpitAPI.ListGrafanaUsers(&cockpit.GlobalAPIListGrafanaUsersRequest{
6162
ProjectID: project.ID,
6263
}, scw.WithAllPages())
@@ -65,6 +66,7 @@ func SweepGrafanaUser(scwClient *scw.Client) error {
6566
}
6667

6768
for _, grafanaUser := range listGrafanaUsers.GrafanaUsers {
69+
//nolint:staticcheck // Deprecated functions are still functional and needed for sweepers
6870
err = cockpitAPI.DeleteGrafanaUser(&cockpit.GlobalAPIDeleteGrafanaUserRequest{
6971
ProjectID: project.ID,
7072
GrafanaUserID: grafanaUser.ID,

0 commit comments

Comments
 (0)