func (a *Alert) Init() error {
	var err error
	a.SearchIndexTPL, err = templatizeHelper(a.SearchIndex, err)
	a.SearchTypeTPL, err = templatizeHelper(a.SearchType, err)
	if a.Search == nil {
		a.SearchTPL, err = templatizeHelper(a.SearchQuery, err)
	} else {
		a.SearchTPL, err = templatizeHelper(&a.Search, err)
	}
	if err != nil {
		return err
	}
	jb, err := jobber.ParseFullTimeSpec(a.Interval)
	if err != nil {
		return fmt.Errorf("parsing interval: %s", err)
	}
	a.Jobber = jb
	return nil
}
Init initializes some internal data inside the Alert, and must be called
after the Alert is unmarshaled from yaml (or otherwise created)
package alert
import (
	"bytes"
	"fmt"
	"text/template"
	"time"
	"github.com/Akagi201/esalert/action"
	"github.com/Akagi201/esalert/context"
	"github.com/Akagi201/esalert/luautil"
	"github.com/Akagi201/esalert/search"
	"github.com/Akagi201/utilgo/jobber"
	log "github.com/sirupsen/logrus"
	yaml "gopkg.in/yaml.v2"
)
type Alert struct {
	Name        string            `yaml:"name"`
	Interval    string            `yaml:"interval"`
	SearchIndex string            `yaml:"search_index"`
	SearchType  string            `yaml:"search_type"`
	Search      search.Dict       `yaml:"search"`
	SearchQuery string            `yaml:"search_query"`
	Process     luautil.LuaRunner `yaml:"process"`
	Jobber         *jobber.FullTimeSpec
	SearchIndexTPL *template.Template
	SearchTypeTPL  *template.Template
	SearchTPL      *template.Template
}
func templatizeHelper(i interface{}, lastErr error) (*template.Template, error) {
	if lastErr != nil {
		return nil, lastErr
	}
	var str string
	if s, ok := i.(string); ok {
		str = s
	} else {
		b, err := yaml.Marshal(i)
		if err != nil {
			return nil, err
		}
		str = string(b)
	}
	return template.New("").Parse(str)
}