From 257f85982597805f6ccb280e43cf2abe0e922b8a Mon Sep 17 00:00:00 2001 From: TwiN Date: Wed, 27 Oct 2021 23:16:05 -0400 Subject: [PATCH] Rename getPagerDutyIntegrationKeyForGroup to getIntegrationKeyForGroup --- alerting/provider/pagerduty/pagerduty.go | 11 ++++------- alerting/provider/pagerduty/pagerduty_test.go | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/alerting/provider/pagerduty/pagerduty.go b/alerting/provider/pagerduty/pagerduty.go index ba62bd69..16f43cb7 100644 --- a/alerting/provider/pagerduty/pagerduty.go +++ b/alerting/provider/pagerduty/pagerduty.go @@ -71,15 +71,15 @@ func (provider *AlertProvider) ToCustomAlertProvider(endpoint *core.Endpoint, al "source": "%s", "severity": "critical" } -}`, provider.getPagerDutyIntegrationKeyForGroup(endpoint.Group), resolveKey, eventAction, message, endpoint.Name), +}`, provider.getIntegrationKeyForGroup(endpoint.Group), resolveKey, eventAction, message, endpoint.Name), Headers: map[string]string{ "Content-Type": "application/json", }, } } -// getPagerDutyIntegrationKeyForGroup returns the appropriate pagerduty integration key for a given group -func (provider *AlertProvider) getPagerDutyIntegrationKeyForGroup(group string) string { +// getIntegrationKeyForGroup returns the appropriate pagerduty integration key for a given group +func (provider *AlertProvider) getIntegrationKeyForGroup(group string) string { if provider.Overrides != nil { for _, override := range provider.Overrides { if group == override.Group { @@ -87,10 +87,7 @@ func (provider *AlertProvider) getPagerDutyIntegrationKeyForGroup(group string) } } } - if provider.IntegrationKey != "" { - return provider.IntegrationKey - } - return "" + return provider.IntegrationKey } // GetDefaultAlert returns the provider's default alert configuration diff --git a/alerting/provider/pagerduty/pagerduty_test.go b/alerting/provider/pagerduty/pagerduty_test.go index 7aebb1be..8e20b1f6 100644 --- a/alerting/provider/pagerduty/pagerduty_test.go +++ b/alerting/provider/pagerduty/pagerduty_test.go @@ -161,7 +161,7 @@ func TestAlertProvider_ToCustomAlertProviderWithTriggeredAlertAndOverride(t *tes } } -func TestAlertProvider_getPagerDutyIntegrationKey(t *testing.T) { +func TestAlertProvider_getIntegrationKeyForGroup(t *testing.T) { scenarios := []struct { Name string Provider AlertProvider @@ -217,7 +217,7 @@ func TestAlertProvider_getPagerDutyIntegrationKey(t *testing.T) { } for _, scenario := range scenarios { t.Run(scenario.Name, func(t *testing.T) { - if output := scenario.Provider.getPagerDutyIntegrationKeyForGroup(scenario.InputGroup); output != scenario.ExpectedOutput { + if output := scenario.Provider.getIntegrationKeyForGroup(scenario.InputGroup); output != scenario.ExpectedOutput { t.Errorf("expected %s, got %s", scenario.ExpectedOutput, output) } })