*Objective:* To remove key/value pair from a go datastructure when a 
condition is met.
*System Information:* Alertmanager's email template (HTML in go) code. 
*Code:*

{{ if gt (len .Alerts.Firing) 0 }
        {{ range .Alerts.Firing }}
                    {{ $labels := .Labels }}
                    {{ range $labels.SortedPairs }}
                        {{ if and (match .Name "alertname") (match .Value 
"Consul-Agent-Unhealthy") }}
                                {{ $labels := $labels.Remove "status" }}
                        {{ end }}
                    {{ end }}
         {{ end }}
{{ end }}

*Error:*
 level=error ts=2020-06-19T16:48:26.364Z caller=notify.go:372 
component=dispatcher msg="Error on notify" err="cancelling notify retry for 
\"email\" due to unrecoverable error: execute html template: template: 
email_template.tmpl:371:25: executing \"email_template.tmpl\" at 
<.Labels.Remove>: can't evaluate field Labels in type template.Pair" 
context_err=null


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/690728e7-41d1-4474-b9ba-2a2f0ecb6f2dn%40googlegroups.com.

Reply via email to