mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
[vmalert] fix linter issues
This commit is contained in:
parent
8fca5f2819
commit
948f8b6b5f
3 changed files with 11 additions and 11 deletions
|
@ -186,8 +186,8 @@ func (r *Rule) newAlert(m datasource.Metric) (*notifier.Alert, error) {
|
|||
return a, err
|
||||
}
|
||||
|
||||
// AlertAPI generates apiAlert object from alert by its id(hash)
|
||||
func (r *Rule) AlertAPI(id uint64) *apiAlert {
|
||||
// AlertAPI generates APIAlert object from alert by its id(hash)
|
||||
func (r *Rule) AlertAPI(id uint64) *APIAlert {
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
a, ok := r.alerts[id]
|
||||
|
@ -197,9 +197,9 @@ func (r *Rule) AlertAPI(id uint64) *apiAlert {
|
|||
return r.newAlertAPI(*a)
|
||||
}
|
||||
|
||||
// AlertAPI generates list of apiAlert objects from existing alerts
|
||||
func (r *Rule) AlertsAPI() []*apiAlert {
|
||||
var alerts []*apiAlert
|
||||
// AlertsAPI generates list of APIAlert objects from existing alerts
|
||||
func (r *Rule) AlertsAPI() []*APIAlert {
|
||||
var alerts []*APIAlert
|
||||
r.mu.RLock()
|
||||
for _, a := range r.alerts {
|
||||
alerts = append(alerts, r.newAlertAPI(*a))
|
||||
|
@ -208,8 +208,8 @@ func (r *Rule) AlertsAPI() []*apiAlert {
|
|||
return alerts
|
||||
}
|
||||
|
||||
func (r *Rule) newAlertAPI(a notifier.Alert) *apiAlert {
|
||||
return &apiAlert{
|
||||
func (r *Rule) newAlertAPI(a notifier.Alert) *APIAlert {
|
||||
return &APIAlert{
|
||||
ID: a.ID,
|
||||
Name: a.Name,
|
||||
Group: a.Group,
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
|
||||
)
|
||||
|
||||
// apiAlert has info for an alert.
|
||||
type apiAlert struct {
|
||||
// APIAlert has info for an alert.
|
||||
type APIAlert struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Group string `json:"group"`
|
||||
|
@ -60,7 +60,7 @@ func (rh *requestHandler) handler(w http.ResponseWriter, r *http.Request) bool {
|
|||
|
||||
type listAlertsResponse struct {
|
||||
Data struct {
|
||||
Alerts []*apiAlert `json:"alerts"`
|
||||
Alerts []*APIAlert `json:"alerts"`
|
||||
} `json:"data"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ func TestHandler(t *testing.T) {
|
|||
}
|
||||
})
|
||||
t.Run("/api/v1/group/0/status", func(t *testing.T) {
|
||||
alert := &apiAlert{}
|
||||
alert := &APIAlert{}
|
||||
getResp(ts.URL+"/api/v1/group/0/status", alert, 200)
|
||||
expAlert := rule.newAlertAPI(*rule.alerts[0])
|
||||
if !reflect.DeepEqual(alert, expAlert) {
|
||||
|
|
Loading…
Reference in a new issue