From e1893769daa37f514851ae5080eb2e1c6eef94b8 Mon Sep 17 00:00:00 2001 From: Jeltz Date: Fri, 31 Dec 2021 15:21:55 +0100 Subject: [PATCH] Don't include trailing \n or
if summary is missing --- bot.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index ef928cd..4d37fea 100755 --- a/bot.py +++ b/bot.py @@ -27,8 +27,10 @@ TEMPLATE_TEXT = ( "{% elif labels.severity == 'warning' %}" "ATTENTION " "{% endif %}" - "{{ labels.alertname }} {{ labels.instance }}\n" - "{{ annotations.summary }}" + "{{ labels.alertname }} {{ labels.instance }}" + "{% if annotations.summary %}" + "\n{{ annotations.summary }}" + "{% endif %}" ) TEMPLATE_HTML = ( @@ -40,8 +42,11 @@ TEMPLATE_HTML = ( "ATTENTION " "{% endif %}" "{{ labels.alertname }} " - "{{ labels.instance }}
" + "{{ labels.instance }}" + "{% if annotations.summary %}" + "
" "
{{ annotations.summary }}
" + "{% endif %}" )