Alerting: Add exported constructor for panelKey (#71872)

Exported constructor for panelKey
This commit is contained in:
Alexander Weaver
2023-07-18 13:37:43 -05:00
committed by GitHub
parent 36264a095f
commit d6db9a5b3c

View File

@@ -57,14 +57,19 @@ type PanelKey struct {
panelID int64
}
func NewPanelKey(orgID int64, dashUID string, panelID int64) PanelKey {
return PanelKey{
orgID: orgID,
dashUID: dashUID,
panelID: panelID,
}
}
// PanelKey attempts to get the key of the panel attached to the given rule. Returns nil if the rule is not attached to a panel.
func parsePanelKey(rule history_model.RuleMeta, logger log.Logger) *PanelKey {
if rule.DashboardUID != "" {
return &PanelKey{
orgID: rule.OrgID,
dashUID: rule.DashboardUID,
panelID: rule.PanelID,
}
key := NewPanelKey(rule.OrgID, rule.DashboardUID, rule.PanelID)
return &key
}
return nil
}