From 5246d1a20e9a9d418f196ae70653db2ea1f4f809 Mon Sep 17 00:00:00 2001 From: Max H <10329648+8ear@users.noreply.github.com> Date: Wed, 9 Oct 2019 09:18:39 +0200 Subject: [PATCH] Update email.go Added SubjectTag as variable --- pkg/notifications/email.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/notifications/email.go b/pkg/notifications/email.go index b5ef979..ef6b3d7 100644 --- a/pkg/notifications/email.go +++ b/pkg/notifications/email.go @@ -24,7 +24,7 @@ const ( // We work around that by holding on to log entries until the update cycle is done. type emailTypeNotifier struct { From, To string - Server, User, Password string + Server, User, Password, SubjectTag string Port int tlsSkipVerify bool entries []*log.Entry @@ -43,6 +43,7 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifie port, _ := flags.GetInt("notification-email-server-port") tlsSkipVerify, _ := flags.GetBool("notification-email-server-tls-skip-verify") delay, _ := flags.GetInt("notification-email-delay") + subjecttag, _ := flags.GetInt("notification-email-subjecttag") n := &emailTypeNotifier{ From: from, @@ -54,6 +55,7 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifie tlsSkipVerify: tlsSkipVerify, logLevels: acceptedLogLevels, delay: time.Duration(delay) * time.Second, + SubjectTag: subjecttag, } log.AddHook(n) @@ -62,7 +64,11 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifie } func (e *emailTypeNotifier) buildMessage(entries []*log.Entry) []byte { - emailSubject := "Watchtower updates" + if SubjectTag == nil { + emailSubject := "Watchtower updates" + } else { + emailSubject := SubjectTag + " Watchtower updates" + } if hostname, err := os.Hostname(); err == nil { emailSubject += " on " + hostname }