mirror of
https://github.com/google/alertmanager-irc-relay.git
synced 2025-01-07 10:42:48 +01:00
format: add string functions
This commit is contained in:
parent
767cb9fb8e
commit
1eb6c5e397
@ -18,6 +18,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
promtmpl "github.com/prometheus/alertmanager/template"
|
promtmpl "github.com/prometheus/alertmanager/template"
|
||||||
@ -29,7 +30,13 @@ type Formatter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewFormatter(config *Config) (*Formatter, error) {
|
func NewFormatter(config *Config) (*Formatter, error) {
|
||||||
tmpl, err := template.New("msg").Parse(config.MsgTemplate)
|
funcMap := template.FuncMap{
|
||||||
|
"ToUpper": strings.ToUpper,
|
||||||
|
"ToLower": strings.ToLower,
|
||||||
|
"Join": strings.Join,
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpl, err := template.New("msg").Funcs(funcMap).Parse(config.MsgTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user