Merge pull request #168 from prometheus/stattmpl

Statically compile default templates
This commit is contained in:
Fabian Reinartz 2015-12-01 18:55:39 +01:00
commit eebde79c66
4 changed files with 270 additions and 20 deletions

View File

@ -44,6 +44,7 @@ assets:
@echo ">> writing assets"
-@$(GO) get -u github.com/jteeuwen/go-bindata/...
@go-bindata $(bindata_flags) -pkg ui -o ui/bindata.go ui/...
@go-bindata $(bindata_flags) -pkg deftmpl -o template/internal/deftmpl/bindata.go template/default.tmpl
.PHONY: all format build test vet assets

File diff suppressed because one or more lines are too long

View File

@ -24,6 +24,7 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/alertmanager/template/internal/deftmpl"
"github.com/prometheus/alertmanager/types"
)
@ -47,6 +48,17 @@ func FromGlobs(paths ...string) (*Template, error) {
t.text = t.text.Funcs(tmpltext.FuncMap(DefaultFuncs))
t.html = t.html.Funcs(tmplhtml.FuncMap(DefaultFuncs))
b, err := deftmpl.Asset("template/default.tmpl")
if err != nil {
return nil, err
}
if t.text, err = t.text.Parse(string(b)); err != nil {
return nil, err
}
if t.html, err = t.html.Parse(string(b)); err != nil {
return nil, err
}
for _, tp := range paths {
if t.text, err = t.text.ParseGlob(tp); err != nil {
return nil, err

File diff suppressed because one or more lines are too long