mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 15:10:12 +01:00
feat(shoutrrr): allow setting URLs from file
This commit is contained in:
parent
12d323354f
commit
624e2a744a
1 changed files with 19 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package flags
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
|
@ -380,6 +381,7 @@ func GetSecretsFromFiles(rootCmd *cobra.Command) {
|
|||
"notification-slack-hook-url",
|
||||
"notification-msteams-hook",
|
||||
"notification-gotify-token",
|
||||
"notification-url",
|
||||
}
|
||||
for _, secret := range secrets {
|
||||
getSecretFromFile(flags, secret)
|
||||
|
|
@ -397,11 +399,25 @@ func getSecretFromFile(flags *pflag.FlagSet, secret string) {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
flag := flags.Lookup(secret)
|
||||
if flag.Value.Type() == "stringArray" {
|
||||
rows := bytes.Split(file, []byte{'\n'})
|
||||
|
||||
for _, row := range rows {
|
||||
err = flags.Set(secret, strings.TrimSpace(string(row)))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
err = flags.Set(secret, strings.TrimSpace(string(file)))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isFile(s string) bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue