Documentation ¶
Index ¶
- Variables
- type Alert
- type Alerts
- type Data
- type FuncMap
- type KV
- type Option
- type Pair
- type Pairs
- type Template
- func (t *Template) Data(recv string, groupLabels model.LabelSet, alerts ...*types.Alert) *Data
- func (t *Template) ExecuteHTMLString(html string, data interface{}) (string, error)
- func (t *Template) ExecuteTextString(text string, data interface{}) (string, error)
- func (t *Template) FromGlob(path string) error
- func (t *Template) Parse(r io.Reader) error
Constants ¶
This section is empty.
Variables ¶
var DefaultFuncs = FuncMap{ "toUpper": strings.ToUpper, "toLower": strings.ToLower, "title": func(text string) string { return cases.Title(language.AmericanEnglish).String(text) }, "trimSpace": strings.TrimSpace, "join": func(sep string, s []string) string { return strings.Join(s, sep) }, "match": regexp.MatchString, "safeHtml": func(text string) tmplhtml.HTML { return tmplhtml.HTML(text) }, "reReplaceAll": func(pattern, repl, text string) string { re := regexp.MustCompile(pattern) return re.ReplaceAllString(text, repl) }, "stringSlice": func(s ...string) []string { return s }, }
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct { Status string `json:"status"` Labels KV `json:"labels"` Annotations KV `json:"annotations"` StartsAt time.Time `json:"startsAt"` EndsAt time.Time `json:"endsAt"` GeneratorURL string `json:"generatorURL"` Fingerprint string `json:"fingerprint"` }
Alert holds one alert for notification templates.
type Alerts ¶
type Alerts []Alert
Alerts is a list of Alert objects.
type Data ¶
type Data struct { Receiver string `json:"receiver"` Status string `json:"status"` Alerts Alerts `json:"alerts"` GroupLabels KV `json:"groupLabels"` CommonLabels KV `json:"commonLabels"` CommonAnnotations KV `json:"commonAnnotations"` ExternalURL string `json:"externalURL"` GroupKey string `json:"groupKey"` }
Data is the data passed to notification templates and webhook pushes.
End-users should not be exposed to Go's type system, as this will confuse them and prevent simple things like simple equality checks to fail. Map everything to float64/string.
type KV ¶
KV is a set of key/value string pairs.
func (KV) SortedPairs ¶
SortedPairs returns a sorted list of key/value pairs.
type Template ¶
Template bundles a text and a html template instance.
func FromGlobs ¶
FromGlobs calls ParseGlob on all path globs provided and returns the resulting Template.
func New ¶
New returns a new Template with the DefaultFuncs added. The DefaultFuncs have precedence over any added custom functions. Options allow customization of the text and html templates in given order.
func (*Template) ExecuteHTMLString ¶
ExecuteHTMLString needs a meaningful doc comment (TODO(fabxc)).
func (*Template) ExecuteTextString ¶
ExecuteTextString needs a meaningful doc comment (TODO(fabxc)).