mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 13:23:09 +01:00
notif: support token as secret for apprise
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
type NotifApprise struct {
|
||||
Endpoint string `yaml:"endpoint,omitempty" json:"endpoint,omitempty" validate:"required"`
|
||||
Token string `yaml:"token,omitempty" json:"token,omitempty" validate:"omitempty"`
|
||||
TokenFile string `yaml:"tokenFile,omitempty" json:"tokenFile,omitempty" validate:"omitempty,file"`
|
||||
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty" validate:"omitempty"`
|
||||
URLs []string `yaml:"urls,omitempty" json:"urls,omitempty" validate:"omitempty"`
|
||||
Timeout *time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty" validate:"required"`
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/crazy-max/diun/v4/internal/model"
|
||||
"github.com/crazy-max/diun/v4/internal/msg"
|
||||
"github.com/crazy-max/diun/v4/internal/notif/notifier"
|
||||
"github.com/crazy-max/diun/v4/pkg/utl"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -75,8 +76,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
||||
|
||||
u.Path = path.Join(u.Path, "notify")
|
||||
|
||||
if c.cfg.Token != "" {
|
||||
u.Path = path.Join(u.Path, c.cfg.Token)
|
||||
if c.cfg.Token != "" || c.cfg.TokenFile != "" {
|
||||
token, err := utl.GetSecret(c.cfg.Token, c.cfg.TokenFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "cannot retrieve token secret for Apprise notifier")
|
||||
}
|
||||
u.Path = path.Join(u.Path, token)
|
||||
}
|
||||
|
||||
q := u.Query()
|
||||
|
||||
Reference in New Issue
Block a user