mirror of
				https://github.com/google/alertmanager-irc-relay.git
				synced 2025-11-03 23:47:24 +01:00 
			
		
		
		
	format: add string functions
This commit is contained in:
		
							parent
							
								
									767cb9fb8e
								
							
						
					
					
						commit
						1eb6c5e397
					
				@ -18,6 +18,7 @@ import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"log"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"text/template"
 | 
			
		||||
 | 
			
		||||
	promtmpl "github.com/prometheus/alertmanager/template"
 | 
			
		||||
@ -29,7 +30,13 @@ type Formatter struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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 {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user