I am defining a notification template and i want to conditionally reassign the summary based on the labels. This is what I have:
{{ define "alerts.summarize" }}
{{ range . -}}
{{ $summary_msg := index .Annotations "summary" }}
{{ if eq .Labels.type "pipeline" }}
{{ $summary_msg = printf "The %s is %s" .Labels.alertname (template "convert" .Values.A) }}
{{- end }}
{{ if eq .Status "firing" }}π¨{{ else }}β
{{- end }} {{ $summary_msg }} {{ if eq .Status "firing" }}π¨{{ else }}β
{{- end }}
{{- end }}
{{- end }}
However, the following line:
{{ $summary_msg = printf "The %s is %s" .Labels.alertname (template "convert" .Values.A) }}
is causing the following failure:
Error: β text templates: [alerting.notifications.templates.invalidFormat] Invalid format of the submitted template
Why? This is valid go syntax!
Note that the issue is not in the message being printed into summary_msg because itβs valid when printing it straight to the console. There seems to be an issue when redirecting the printf output to the summary_msg