style: resovle linting issues

pull/26/head
kha7iq 4 years ago
parent 603aa5ee9e
commit edd49a3f16

@ -66,7 +66,7 @@ All configuration options are also available via environment variables.`,
discordSvc := discord.New() discordSvc := discord.New()
if err := discordSvc.AuthenticateWithBotToken(discordOpts.Token); err != nil { if err := discordSvc.AuthenticateWithBotToken(discordOpts.Token); err != nil {
return fmt.Errorf("unable to authenticate %v\n", err) return fmt.Errorf("unable to authenticate %v", err)
} }
chn := strings.Split(discordOpts.Channel, ",") chn := strings.Split(discordOpts.Channel, ",")

@ -18,7 +18,7 @@ type matterMost struct {
Token string Token string
ServerURL string ServerURL string
Scheme string Scheme string
ApiURL string APIURL string
Message string Message string
ChanIDs string ChanIDs string
} }
@ -108,7 +108,7 @@ You can specify multiple channels by separating the value with ','.`,
EnvVars: []string{"MATTERMOST_SCHEME"}, EnvVars: []string{"MATTERMOST_SCHEME"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Destination: &mattermostOpts.ApiURL, Destination: &mattermostOpts.APIURL,
Name: "api", Name: "api",
Value: "/api/v4/posts", Value: "/api/v4/posts",
Usage: "Unless using older version of api default is fine.", Usage: "Unless using older version of api default is fine.",
@ -116,7 +116,7 @@ You can specify multiple channels by separating the value with ','.`,
}, },
}, },
Action: func(ctx *cli.Context) error { Action: func(ctx *cli.Context) error {
endPointURL := mattermostOpts.Scheme + "://" + mattermostOpts.ServerURL + mattermostOpts.ApiURL endPointURL := mattermostOpts.Scheme + "://" + mattermostOpts.ServerURL + mattermostOpts.APIURL
// Create a Bearer string by appending string access token // Create a Bearer string by appending string access token
bearer := "Bearer " + mattermostOpts.Token bearer := "Bearer " + mattermostOpts.Token
@ -129,7 +129,7 @@ You can specify multiple channels by separating the value with ','.`,
return fmt.Errorf(EmptyChannel) return fmt.Errorf(EmptyChannel)
} }
jsonData, err := toJson(v, fullMessage) jsonData, err := toJSON(v, fullMessage)
if err != nil { if err != nil {
return fmt.Errorf("error parsing json\n[ERROR] - %v", err) return fmt.Errorf("error parsing json\n[ERROR] - %v", err)
} }
@ -137,7 +137,6 @@ You can specify multiple channels by separating the value with ','.`,
if err := sendMattermost(endPointURL, bearer, jsonData); err != nil { if err := sendMattermost(endPointURL, bearer, jsonData); err != nil {
return fmt.Errorf("failed to send message\n[ERROR] - %v", err) return fmt.Errorf("failed to send message\n[ERROR] - %v", err)
} }
} }
return nil return nil
}, },
@ -145,7 +144,7 @@ You can specify multiple channels by separating the value with ','.`,
} }
// toJson takes strings and convert them to json byte array // toJson takes strings and convert them to json byte array
func toJson(channel string, msg string) ([]byte, error) { func toJSON(channel string, msg string) ([]byte, error) {
m := make(map[string]string, 2) m := make(map[string]string, 2)
m["channel_id"] = channel m["channel_id"] = channel
m["message"] = msg m["message"] = msg

@ -63,7 +63,6 @@ you can add permissions for multiple channels to single webhook.`,
return fmt.Errorf(EmptyChannel) return fmt.Errorf(EmptyChannel)
} }
teamsSvc.AddReceivers(v) teamsSvc.AddReceivers(v)
} }
notifier.UseServices(teamsSvc) notifier.UseServices(teamsSvc)

@ -105,7 +105,6 @@ Multiple device nicknames or numbers can be used separated by comma.`,
); err != nil { ); err != nil {
return err return err
} }
} }
default: default:
pushBulletSvc := pushbullet.New(pushBulletOpts.Token) pushBulletSvc := pushbullet.New(pushBulletOpts.Token)
@ -127,7 +126,6 @@ Multiple device nicknames or numbers can be used separated by comma.`,
); err != nil { ); err != nil {
return err return err
} }
} }
log.Println("Successfully sent!") log.Println("Successfully sent!")

@ -13,7 +13,7 @@ import (
type rocketChat struct { type rocketChat struct {
Token string Token string
UserId string UserID string
Message string Message string
Channel string Channel string
Title string Title string
@ -43,7 +43,7 @@ All configuration options are also available via environment variables.`,
" --channel 'alert' --msg 'some message'", " --channel 'alert' --msg 'some message'",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Destination: &rocketChatOpts.UserId, Destination: &rocketChatOpts.UserID,
Name: "userid", Name: "userid",
Aliases: []string{"id"}, Aliases: []string{"id"},
Required: true, Required: true,
@ -99,7 +99,7 @@ All configuration options are also available via environment variables.`,
notifier := notify.New() notifier := notify.New()
rocketChatSvc, err := rocketchat.New(rocketChatOpts.ServerURL, rocketChatOpts.Scheme, rocketChatSvc, err := rocketchat.New(rocketChatOpts.ServerURL, rocketChatOpts.Scheme,
rocketChatOpts.UserId, rocketChatOpts.Token) rocketChatOpts.UserID, rocketChatOpts.Token)
if err != nil { if err != nil {
return err return err
} }

@ -77,9 +77,9 @@ All configuration options are also available via environment variables.`,
if len(v) <= 0 { if len(v) <= 0 {
return fmt.Errorf(EmptyChannel) return fmt.Errorf(EmptyChannel)
} }
k, err := strconv.Atoi(v) k, errStr := strconv.Atoi(v)
if err != nil { if errStr != nil {
log.Println(err) return errStr
} }
telegramSvc.AddReceivers(int64(k)) telegramSvc.AddReceivers(int64(k))
} }

Loading…
Cancel
Save