Некоторые проверки не удались
CI / test (push) Successful in 2m5s
Docker / Build and publish worker image (push) Failing after 31s
49 строки
1.3 KiB
Go
49 строки
1.3 KiB
Go
package notifyrender
|
|
|
|
import (
|
|
"bytes"
|
|
"html/template"
|
|
|
|
"rocketgit.ru/rsmon/worker/app/models"
|
|
)
|
|
|
|
var (
|
|
// ExpSubject provides functionality.
|
|
ExpSubject *template.Template
|
|
// ExpBody provides functionality.
|
|
ExpBody *template.Template
|
|
// ExpHTML provides functionality.
|
|
ExpHTML *template.Template
|
|
)
|
|
|
|
func init() {
|
|
ExpSubject = template.Must(template.New("exp_subject").Parse(`Скоро истекает {{.GetLabel}} ({{.KindLabel}}) по {{.Monitor.GetLabel}}`))
|
|
// ExpBody provides functionality.
|
|
ExpBody = template.Must(template.New("exp_body").Parse(`Монитор {{.Monitor.GetLabel}}
|
|
{{.Expires.Format "02.01.2006 15:04:05"}} истекает {{.GetLabel}} ({{.KindLabel}})
|
|
`))
|
|
ExpHTML = template.Must(template.New("exp_html").Parse(`Монитор {{.Monitor.GetLabel}}
|
|
{{.Expires.Format "02.01.2006 15:04:05"}} истекает {{.GetLabel}} <strong>({{.KindLabel}})</strong>
|
|
`))
|
|
}
|
|
|
|
// TextExpires provides functionality.
|
|
func TextExpires(check *models.Check) (bytes.Buffer, bytes.Buffer, bytes.Buffer, bytes.Buffer) {
|
|
var err error
|
|
var subject, textBody, htmlBody bytes.Buffer
|
|
|
|
err = ExpSubject.Execute(&subject, check)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
err = ExpBody.Execute(&textBody, check)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
err = ExpHTML.Execute(&htmlBody, check)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return subject, textBody, textBody, htmlBody
|
|
}
|