feat: allow hostname override for notifiers (#994)

* feat: allow hostname override for email notifier

As it currently stands all notifiers utilise `os.Hostname` to populate their titles/subjects.

When utilising Docker with a bridged network if you set the hostname for a container to an external DNS hostname Docker's internal DNS resolver will override said hostname for all containers within the bridged network.

This change allows a user to specify what hostname should be represented in the email notifications without having to change the `os.Hostname`.

* feat: allow custom hostname for all notifiers

* docs: adjust notification hostname flag
This commit is contained in:
Amir Zarrinkafsh 2021-06-24 08:29:20 +10:00 committed by GitHub
parent f508c92ae0
commit dc12a1ac7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 20 deletions

View file

@ -60,14 +60,14 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Convert
return n
}
func (e *emailTypeNotifier) GetURL() (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(),
Subject: e.getSubject(c),
Username: e.User,
Password: e.Password,
UseStartTLS: !e.tlsSkipVerify,
@ -87,8 +87,8 @@ func (e *emailTypeNotifier) GetURL() (string, error) {
return conf.GetURL().String(), nil
}
func (e *emailTypeNotifier) getSubject() string {
subject := GetTitle()
func (e *emailTypeNotifier) getSubject(c *cobra.Command) string {
subject := GetTitle(c)
if e.SubjectTag != "" {
subject = e.SubjectTag + " " + subject