Alerting: declare constants for __dashboardUid__ and __panelId__ literals (#39976)

This commit is contained in:
Yuriy Tseretyan
2021-10-07 17:30:06 -04:00
committed by GitHub
parent c8651c46d0
commit 5836def6c2
6 changed files with 28 additions and 20 deletions
@@ -8,6 +8,8 @@ import (
"strconv"
"strings"
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
pb "github.com/prometheus/alertmanager/silence/silencepb"
"xorm.io/xorm"
@@ -148,13 +150,13 @@ func (m *updateDashboardUIDPanelIDMigration) Exec(sess *xorm.Session, mg *migrat
dashboardUID *string
panelID *int64
)
if s, ok := next.Annotations["__dashboardUid__"]; ok {
if s, ok := next.Annotations[ngmodels.DashboardUIDAnnotation]; ok {
dashboardUID = &s
}
if s, ok := next.Annotations["__panelId__"]; ok {
if s, ok := next.Annotations[ngmodels.PanelIDAnnotation]; ok {
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return fmt.Errorf("the __panelId__ annotation does not contain a valid Panel ID: %w", err)
return fmt.Errorf("the %s annotation does not contain a valid Panel ID: %w", ngmodels.PanelIDAnnotation, err)
}
panelID = &i
}