mirror of
https://github.com/containrrr/watchtower.git
synced 2026-03-07 05:10:18 +01:00
fix tests, upgrade snakes
This commit is contained in:
parent
aa50cdf9bc
commit
1165f31ca0
15 changed files with 669 additions and 283 deletions
|
|
@ -7,8 +7,7 @@ import (
|
|||
shoutrrrGotify "github.com/containrrr/shoutrrr/pkg/services/gotify"
|
||||
t "github.com/containrrr/watchtower/pkg/types"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -19,37 +18,34 @@ type gotifyTypeNotifier struct {
|
|||
gotifyURL string
|
||||
gotifyAppToken string
|
||||
gotifyInsecureSkipVerify bool
|
||||
logLevels []log.Level
|
||||
}
|
||||
|
||||
func newGotifyNotifier(c *cobra.Command, levels []log.Level) t.ConvertibleNotifier {
|
||||
flags := c.PersistentFlags()
|
||||
func newGotifyNotifier() t.ConvertibleNotifier {
|
||||
|
||||
apiURL := getGotifyURL(flags)
|
||||
token := getGotifyToken(flags)
|
||||
apiURL := getGotifyURL()
|
||||
token := getGotifyToken()
|
||||
|
||||
skipVerify, _ := flags.GetBool("notification-gotify-tls-skip-verify")
|
||||
skipVerify := viper.GetBool("notification-gotify-tls-skip-verify")
|
||||
|
||||
n := &gotifyTypeNotifier{
|
||||
gotifyURL: apiURL,
|
||||
gotifyAppToken: token,
|
||||
gotifyInsecureSkipVerify: skipVerify,
|
||||
logLevels: levels,
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func getGotifyToken(flags *pflag.FlagSet) string {
|
||||
gotifyToken, _ := flags.GetString("notification-gotify-token")
|
||||
func getGotifyToken() string {
|
||||
gotifyToken := viper.GetString("notification-gotify-token")
|
||||
if len(gotifyToken) < 1 {
|
||||
log.Fatal("Required argument --notification-gotify-token(cli) or WATCHTOWER_NOTIFICATION_GOTIFY_TOKEN(env) is empty.")
|
||||
}
|
||||
return gotifyToken
|
||||
}
|
||||
|
||||
func getGotifyURL(flags *pflag.FlagSet) string {
|
||||
gotifyURL, _ := flags.GetString("notification-gotify-url")
|
||||
func getGotifyURL() string {
|
||||
gotifyURL := viper.GetString("notification-gotify-url")
|
||||
|
||||
if len(gotifyURL) < 1 {
|
||||
log.Fatal("Required argument --notification-gotify-url(cli) or WATCHTOWER_NOTIFICATION_GOTIFY_URL(env) is empty.")
|
||||
|
|
@ -62,7 +58,7 @@ func getGotifyURL(flags *pflag.FlagSet) string {
|
|||
return gotifyURL
|
||||
}
|
||||
|
||||
func (n *gotifyTypeNotifier) GetURL(c *cobra.Command, title string) (string, error) {
|
||||
func (n *gotifyTypeNotifier) GetURL(title string) (string, error) {
|
||||
apiURL, err := url.Parse(n.gotifyURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue