2023-03-27 21:29:25 +02:00
|
|
|
package emailUi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"github.com/pkg/errors"
|
2023-04-03 20:19:43 +02:00
|
|
|
"text/template"
|
2023-03-27 21:29:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type WarningEmail struct {
|
|
|
|
EmailAddress string
|
|
|
|
Detail string
|
2023-03-28 20:39:42 +02:00
|
|
|
Version string
|
2023-03-27 21:29:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (we WarningEmail) MergeTemplate(filename string) (string, error) {
|
|
|
|
t, err := template.ParseFS(FS, filename)
|
|
|
|
if err != nil {
|
|
|
|
return "", errors.Wrapf(err, "error parsing warning email template '%v'", filename)
|
|
|
|
}
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
if err := t.Execute(buf, we); err != nil {
|
|
|
|
return "", errors.Wrapf(err, "error executing warning email template '%v'", filename)
|
|
|
|
}
|
|
|
|
return buf.String(), nil
|
|
|
|
}
|