mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
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:
parent
f508c92ae0
commit
dc12a1ac7f
9 changed files with 45 additions and 20 deletions
|
|
@ -98,7 +98,7 @@ func (n *Notifier) getNotificationTypes(cmd *cobra.Command, levels []log.Level,
|
|||
continue
|
||||
}
|
||||
|
||||
shoutrrrURL, err := legacyNotifier.GetURL()
|
||||
shoutrrrURL, err := legacyNotifier.GetURL(cmd)
|
||||
if err != nil {
|
||||
log.Fatal("failed to create notification config:", err)
|
||||
}
|
||||
|
|
@ -139,10 +139,16 @@ func (n *Notifier) Close() {
|
|||
}
|
||||
|
||||
// GetTitle returns a common notification title with hostname appended
|
||||
func GetTitle() (title string) {
|
||||
func GetTitle(c *cobra.Command) (title string) {
|
||||
title = "Watchtower updates"
|
||||
|
||||
if hostname, err := os.Hostname(); err == nil {
|
||||
f := c.PersistentFlags()
|
||||
|
||||
hostname, _ := f.GetString("notifications-hostname")
|
||||
|
||||
if hostname != "" {
|
||||
title += " on " + hostname
|
||||
} else if hostname, err := os.Hostname(); err == nil {
|
||||
title += " on " + hostname
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue