Added the software version to the mail default template and cli help text, updated README and build script
This commit is contained in:
parent
e9f39d25b4
commit
9f31bf557d
6 changed files with 33 additions and 17 deletions
17
template.go
17
template.go
|
@ -26,7 +26,16 @@ Affected Products:{{ range $product := .ProductNames }}
|
|||
|
||||
Assigned CVEs:{{ range $cve := .Cves }}
|
||||
- {{ $cve }} -> https://www.cve.org/CVERecord?id={{ $cve }}
|
||||
{{- end }}{{ end }}`
|
||||
{{- end }}{{ end }}
|
||||
|
||||
|
||||
Sent by WidNotifier {{ .WidNotifierVersion }}
|
||||
`
|
||||
|
||||
type TemplateData struct {
|
||||
WidNotice
|
||||
WidNotifierVersion string
|
||||
}
|
||||
|
||||
type MailTemplateConfig struct {
|
||||
SubjectTemplate string `json:"subject"`
|
||||
|
@ -38,14 +47,14 @@ type MailTemplate struct {
|
|||
BodyTemplate template.Template
|
||||
}
|
||||
|
||||
func (t MailTemplate) generate(notice WidNotice) (MailContent, error) {
|
||||
func (t MailTemplate) generate(data TemplateData) (MailContent, error) {
|
||||
c := MailContent{}
|
||||
buffer := &bytes.Buffer{}
|
||||
err := t.SubjectTemplate.Execute(buffer, notice)
|
||||
err := t.SubjectTemplate.Execute(buffer, data)
|
||||
if err != nil { return c, err }
|
||||
c.Subject = buffer.String()
|
||||
buffer.Truncate(0) // we can recycle our buffer
|
||||
err = t.BodyTemplate.Execute(buffer, notice)
|
||||
err = t.BodyTemplate.Execute(buffer, data)
|
||||
if err != nil { return c, err }
|
||||
c.Body = buffer.String()
|
||||
return c, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue