From 0b445c1d4777264799df6076f296c72e94adddce Mon Sep 17 00:00:00 2001 From: razzkumar Date: Wed, 25 Sep 2019 16:56:38 +0545 Subject: [PATCH] slack error message display string fixes --- deployment/utils/slack/slack.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/deployment/utils/slack/slack.go b/deployment/utils/slack/slack.go index 6fb55d3..00ae0c2 100644 --- a/deployment/utils/slack/slack.go +++ b/deployment/utils/slack/slack.go @@ -12,7 +12,15 @@ func Notify(url string, text string, color string) { message := strings.Replace(text, "\"", "'", -1) - content := fmt.Sprintf(`{"attachments": [{"text": %q, "color": "%s"}]}`, "```"+message+"```", color) + var content string + + if strings.Contains(message, "error") { + + content = fmt.Sprintf(`{"attachments": [{"text": %q, "color": "%s"}]}`, "```"+message+"```", color) + } else { + + content = fmt.Sprintf(`{"attachments": [{"text": %q, "color": "%s"}]}`, message, color) + } http.Client.R(). SetHeader("Content-Type", "application/json").