mirror of
https://github.com/prometheus/alertmanager
synced 2025-02-16 10:37:09 +00:00
Statically compile default templates
This commit is contained in:
parent
fee23ae610
commit
1629e9d166
1
Makefile
1
Makefile
@ -44,6 +44,7 @@ assets:
|
|||||||
@echo ">> writing assets"
|
@echo ">> writing assets"
|
||||||
-@$(GO) get -u github.com/jteeuwen/go-bindata/...
|
-@$(GO) get -u github.com/jteeuwen/go-bindata/...
|
||||||
@go-bindata $(bindata_flags) -pkg ui -o ui/bindata.go ui/...
|
@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
|
.PHONY: all format build test vet assets
|
||||||
|
237
template/internal/deftmpl/bindata.go
Normal file
237
template/internal/deftmpl/bindata.go
Normal file
File diff suppressed because one or more lines are too long
@ -24,6 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
|
|
||||||
|
"github.com/prometheus/alertmanager/template/internal/deftmpl"
|
||||||
"github.com/prometheus/alertmanager/types"
|
"github.com/prometheus/alertmanager/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,6 +48,17 @@ func FromGlobs(paths ...string) (*Template, error) {
|
|||||||
t.text = t.text.Funcs(tmpltext.FuncMap(DefaultFuncs))
|
t.text = t.text.Funcs(tmpltext.FuncMap(DefaultFuncs))
|
||||||
t.html = t.html.Funcs(tmplhtml.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 {
|
for _, tp := range paths {
|
||||||
if t.text, err = t.text.ParseGlob(tp); err != nil {
|
if t.text, err = t.text.ParseGlob(tp); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user