mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
preparations for soft deprecation of legacy notification args (#1377)
Co-authored-by: Simon Aronsson <simme@arcticbit.se>
This commit is contained in:
parent
2102a056de
commit
cb555f539d
18 changed files with 505 additions and 167 deletions
|
|
@ -15,17 +15,16 @@ const (
|
|||
)
|
||||
|
||||
type emailTypeNotifier struct {
|
||||
From, To string
|
||||
Server, User, Password, SubjectTag string
|
||||
Port int
|
||||
tlsSkipVerify bool
|
||||
entries []*log.Entry
|
||||
logLevels []log.Level
|
||||
delay time.Duration
|
||||
From, To string
|
||||
Server, User, Password string
|
||||
Port int
|
||||
tlsSkipVerify bool
|
||||
entries []*log.Entry
|
||||
delay time.Duration
|
||||
}
|
||||
|
||||
func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.ConvertibleNotifier {
|
||||
flags := c.PersistentFlags()
|
||||
func newEmailNotifier(c *cobra.Command) t.ConvertibleNotifier {
|
||||
flags := c.Flags()
|
||||
|
||||
from, _ := flags.GetString("notification-email-from")
|
||||
to, _ := flags.GetString("notification-email-to")
|
||||
|
|
@ -35,7 +34,6 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Convert
|
|||
port, _ := flags.GetInt("notification-email-server-port")
|
||||
tlsSkipVerify, _ := flags.GetBool("notification-email-server-tls-skip-verify")
|
||||
delay, _ := flags.GetInt("notification-email-delay")
|
||||
subjecttag, _ := flags.GetString("notification-email-subjecttag")
|
||||
|
||||
n := &emailTypeNotifier{
|
||||
entries: []*log.Entry{},
|
||||
|
|
@ -46,22 +44,19 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Convert
|
|||
Password: password,
|
||||
Port: port,
|
||||
tlsSkipVerify: tlsSkipVerify,
|
||||
logLevels: acceptedLogLevels,
|
||||
delay: time.Duration(delay) * time.Second,
|
||||
SubjectTag: subjecttag,
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (e *emailTypeNotifier) GetURL(c *cobra.Command, title string) (string, error) {
|
||||
func (e *emailTypeNotifier) GetURL(c *cobra.Command) (string, error) {
|
||||
conf := &shoutrrrSmtp.Config{
|
||||
FromAddress: e.From,
|
||||
FromName: "Watchtower",
|
||||
ToAddresses: []string{e.To},
|
||||
Port: uint16(e.Port),
|
||||
Host: e.Server,
|
||||
Subject: e.getSubject(c, title),
|
||||
Username: e.User,
|
||||
Password: e.Password,
|
||||
UseStartTLS: !e.tlsSkipVerify,
|
||||
|
|
@ -84,11 +79,3 @@ func (e *emailTypeNotifier) GetURL(c *cobra.Command, title string) (string, erro
|
|||
func (e *emailTypeNotifier) GetDelay() time.Duration {
|
||||
return e.delay
|
||||
}
|
||||
|
||||
func (e *emailTypeNotifier) getSubject(_ *cobra.Command, title string) string {
|
||||
if e.SubjectTag != "" {
|
||||
return e.SubjectTag + " " + title
|
||||
}
|
||||
|
||||
return title
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue