switch urfave to cobra

This commit is contained in:
Simon Aronsson 2019-06-22 22:04:36 +02:00
parent 339df55cc6
commit 998e8052c5
10 changed files with 581 additions and 398 deletions

View file

@ -4,10 +4,10 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"net/http"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
"io/ioutil"
)
@ -21,17 +21,20 @@ type msTeamsTypeNotifier struct {
data bool
}
func newMsTeamsNotifier(c *cli.Context, acceptedLogLevels []log.Level) typeNotifier {
func newMsTeamsNotifier(cmd *cobra.Command, acceptedLogLevels []log.Level) typeNotifier {
webHookURL := c.GlobalString("notification-msteams-hook")
flags := cmd.PersistentFlags()
webHookURL, _ := flags.GetString("notification-msteams-hook")
if len(webHookURL) <= 0 {
log.Fatal("Required argument --notification-msteams-hook(cli) or WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL(env) is empty.")
}
withData, _ := flags.GetBool("notification-msteams-data")
n := &msTeamsTypeNotifier{
levels: acceptedLogLevels,
webHookURL: webHookURL,
data: c.GlobalBool("notification-msteams-data"),
data: withData,
}
log.AddHook(n)