From d6db9a5b3cd9af284bdcbb7a8ed0f9532eeaabc9 Mon Sep 17 00:00:00 2001 From: Alexander Weaver Date: Tue, 18 Jul 2023 13:37:43 -0500 Subject: [PATCH] Alerting: Add exported constructor for panelKey (#71872) Exported constructor for panelKey --- pkg/services/ngalert/state/historian/core.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/services/ngalert/state/historian/core.go b/pkg/services/ngalert/state/historian/core.go index 4423cb401e5..c84d18b2a7d 100644 --- a/pkg/services/ngalert/state/historian/core.go +++ b/pkg/services/ngalert/state/historian/core.go @@ -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 }