|
|
@ -23,13 +23,13 @@ const (
|
|
|
|
// - It would only send errors
|
|
|
|
// - It would only send errors
|
|
|
|
// We work around that by holding on to log entries until the update cycle is done.
|
|
|
|
// We work around that by holding on to log entries until the update cycle is done.
|
|
|
|
type emailTypeNotifier struct {
|
|
|
|
type emailTypeNotifier struct {
|
|
|
|
From, To string
|
|
|
|
From, To string
|
|
|
|
Server, User, Password, SubjectTag string
|
|
|
|
Server, User, Password, SubjectTag string
|
|
|
|
Port int
|
|
|
|
Port int
|
|
|
|
tlsSkipVerify bool
|
|
|
|
tlsSkipVerify bool
|
|
|
|
entries []*log.Entry
|
|
|
|
entries []*log.Entry
|
|
|
|
logLevels []log.Level
|
|
|
|
logLevels []log.Level
|
|
|
|
delay time.Duration
|
|
|
|
delay time.Duration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifier {
|
|
|
|
func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifier {
|
|
|
@ -64,10 +64,12 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifie
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (e *emailTypeNotifier) buildMessage(entries []*log.Entry) []byte {
|
|
|
|
func (e *emailTypeNotifier) buildMessage(entries []*log.Entry) []byte {
|
|
|
|
if SubjectTag == "" {
|
|
|
|
var emailSubject string
|
|
|
|
emailSubject := "Watchtower updates"
|
|
|
|
|
|
|
|
|
|
|
|
if e.SubjectTag == "" {
|
|
|
|
|
|
|
|
emailSubject = "Watchtower updates"
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
emailSubject := SubjectTag + " Watchtower updates"
|
|
|
|
emailSubject = e.SubjectTag + " Watchtower updates"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if hostname, err := os.Hostname(); err == nil {
|
|
|
|
if hostname, err := os.Hostname(); err == nil {
|
|
|
|
emailSubject += " on " + hostname
|
|
|
|
emailSubject += " on " + hostname
|
|
|
@ -134,7 +136,7 @@ func (e *emailTypeNotifier) SendNotification() {
|
|
|
|
time.Sleep(e.delay)
|
|
|
|
time.Sleep(e.delay)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
e.sendEntries(e.entries)
|
|
|
|
e.sendEntries(e.entries)
|
|
|
|
e.entries = nil
|
|
|
|
e.entries = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|