diff --git a/alerting/provider/slack/slack.go b/alerting/provider/slack/slack.go index a7d1f153..2c613a58 100644 --- a/alerting/provider/slack/slack.go +++ b/alerting/provider/slack/slack.go @@ -2,6 +2,7 @@ package slack import ( "fmt" + "github.com/TwinProduction/gatus/alerting/provider/custom" "github.com/TwinProduction/gatus/core" ) @@ -18,8 +19,7 @@ func (provider *AlertProvider) IsValid() bool { // ToCustomAlertProvider converts the provider into a custom.AlertProvider func (provider *AlertProvider) ToCustomAlertProvider(service *core.Service, alert *core.Alert, result *core.Result, resolved bool) *custom.AlertProvider { - var message string - var color string + var message, color, results string if resolved { message = fmt.Sprintf("An alert for *%s* has been resolved after passing successfully %d time(s) in a row", service.Name, alert.SuccessThreshold) color = "#36A64F" @@ -27,7 +27,6 @@ func (provider *AlertProvider) ToCustomAlertProvider(service *core.Service, aler message = fmt.Sprintf("An alert for *%s* has been triggered due to having failed %d time(s) in a row", service.Name, alert.FailureThreshold) color = "#DD0000" } - var results string for _, conditionResult := range result.ConditionResults { var prefix string if conditionResult.Success { diff --git a/alerting/provider/slack/slack_test.go b/alerting/provider/slack/slack_test.go index 9b853d5b..4f1c8d2d 100644 --- a/alerting/provider/slack/slack_test.go +++ b/alerting/provider/slack/slack_test.go @@ -1,9 +1,10 @@ package slack import ( - "github.com/TwinProduction/gatus/core" "strings" "testing" + + "github.com/TwinProduction/gatus/core" ) func TestAlertProvider_IsValid(t *testing.T) {