mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
notif: support token as secret for apprise
This commit is contained in:
@@ -9,6 +9,7 @@ Notifications can be sent using an apprise api instance.
|
|||||||
notif:
|
notif:
|
||||||
apprise:
|
apprise:
|
||||||
endpoint: http://apprise:8000
|
endpoint: http://apprise:8000
|
||||||
|
token: abc
|
||||||
tags:
|
tags:
|
||||||
- diun
|
- diun
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
@@ -17,15 +18,16 @@ Notifications can be sent using an apprise api instance.
|
|||||||
Docker tag {{ .Entry.Image }} which you subscribed to through {{ .Entry.Provider }} provider has been released.
|
Docker tag {{ .Entry.Image }} which you subscribed to through {{ .Entry.Provider }} provider has been released.
|
||||||
```
|
```
|
||||||
|
|
||||||
| Name | Default | Description |
|
| Name | Default | Description |
|
||||||
|---------------------|-------------------------------------|------------------------------------------------------------------------------|
|
|-----------------|-------------------------------------|----------------------------------------------------------------------------|
|
||||||
| `endpoint`[^1] | | Hostname and port of your apprise api instance |
|
| `endpoint`[^1] | | Hostname and port of your apprise api instance |
|
||||||
| `token`[^2] | | token representing your config file (Config Key) |
|
| `token`[^2] | | token representing your config file (Config Key) |
|
||||||
| `tags` | | List of Tags in your config file you want to notify |
|
| `tokenFile` | | Use content of secret file as application token if `token` not defined |
|
||||||
| `urls`[^2] | | List of [URLs](https://github.com/caronc/apprise/wiki/URLBasics) to notify |
|
| `tags` | | List of Tags in your config file you want to notify |
|
||||||
| `timeout` | `10s` | Timeout specifies a time limit for the request to be made |
|
| `urls`[^2] | | List of [URLs](https://github.com/caronc/apprise/wiki/URLBasics) to notify |
|
||||||
| `templateTitle` | See [below](#default-templatetitle) | [Notification template](../faq.md#notification-template) for message title |
|
| `timeout` | `10s` | Timeout specifies a time limit for the request to be made |
|
||||||
| `templateBody` | See [below](#default-templatebody) | [Notification template](../faq.md#notification-template) for message body |
|
| `templateTitle` | See [below](#default-templatetitle) | [Notification template](../faq.md#notification-template) for message title |
|
||||||
|
| `templateBody` | See [below](#default-templatebody) | [Notification template](../faq.md#notification-template) for message body |
|
||||||
|
|
||||||
!!! abstract "Environment variables"
|
!!! abstract "Environment variables"
|
||||||
* `DIUN_NOTIF_APPRISE_ENDPOINT`
|
* `DIUN_NOTIF_APPRISE_ENDPOINT`
|
||||||
@@ -49,4 +51,4 @@ Notifications can be sent using an apprise api instance.
|
|||||||
```
|
```
|
||||||
|
|
||||||
[^1]: Value required
|
[^1]: Value required
|
||||||
[^2]: One of these 2 values is required
|
[^2]: One of these 2 values is required
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
type NotifApprise struct {
|
type NotifApprise struct {
|
||||||
Endpoint string `yaml:"endpoint,omitempty" json:"endpoint,omitempty" validate:"required"`
|
Endpoint string `yaml:"endpoint,omitempty" json:"endpoint,omitempty" validate:"required"`
|
||||||
Token string `yaml:"token,omitempty" json:"token,omitempty" validate:"omitempty"`
|
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"`
|
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty" validate:"omitempty"`
|
||||||
URLs []string `yaml:"urls,omitempty" json:"urls,omitempty" validate:"omitempty"`
|
URLs []string `yaml:"urls,omitempty" json:"urls,omitempty" validate:"omitempty"`
|
||||||
Timeout *time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty" validate:"required"`
|
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/model"
|
||||||
"github.com/crazy-max/diun/v4/internal/msg"
|
"github.com/crazy-max/diun/v4/internal/msg"
|
||||||
"github.com/crazy-max/diun/v4/internal/notif/notifier"
|
"github.com/crazy-max/diun/v4/internal/notif/notifier"
|
||||||
|
"github.com/crazy-max/diun/v4/pkg/utl"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -75,8 +76,12 @@ func (c *Client) Send(entry model.NotifEntry) error {
|
|||||||
|
|
||||||
u.Path = path.Join(u.Path, "notify")
|
u.Path = path.Join(u.Path, "notify")
|
||||||
|
|
||||||
if c.cfg.Token != "" {
|
if c.cfg.Token != "" || c.cfg.TokenFile != "" {
|
||||||
u.Path = path.Join(u.Path, c.cfg.Token)
|
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()
|
q := u.Query()
|
||||||
|
|||||||
Reference in New Issue
Block a user