fix doc and lint warns for the cmd package

This commit is contained in:
mlsmaycon 2021-05-15 15:33:07 +05:00
parent 6d339295be
commit 73720951d7
4 changed files with 11 additions and 7 deletions

View File

@ -40,6 +40,6 @@ var (
func init() {
addPeerCmd.PersistentFlags().StringVar(&key, "key", "", "Wireguard public key of the remote peer")
addPeerCmd.PersistentFlags().StringVar(&allowedIPs, "allowedIPs", "", "Wireguard Allowed IPs for the remote peer, e.g 10.30.30.2/32")
addPeerCmd.MarkPersistentFlagRequired("key")
addPeerCmd.MarkPersistentFlagRequired("allowedIPs")
addPeerCmd.MarkPersistentFlagRequired("key") //nolint
addPeerCmd.MarkPersistentFlagRequired("allowedIPs") //nolint
}

View File

@ -8,6 +8,7 @@ import (
"os"
)
// Config Configuration type
type Config struct {
// Wireguard private key of local peer
PrivateKey string

View File

@ -109,10 +109,10 @@ func init() {
//todo user:password@protocol:host:port not the best way to pass TURN credentials, do it according to https://tools.ietf.org/html/rfc7065 E.g. use oauth
initCmd.PersistentFlags().StringVar(&turnURLs, "turnURLs", "", "Comma separated TURN server URLs: user:password@protocol:host:port, e.g. user:password@turn:stun.wiretrustee.com:3468")
//initCmd.MarkPersistentFlagRequired("configPath")
initCmd.MarkPersistentFlagRequired("wgLocalAddr")
initCmd.MarkPersistentFlagRequired("signalAddr")
initCmd.MarkPersistentFlagRequired("stunURLs")
initCmd.MarkPersistentFlagRequired("turnURLs")
initCmd.MarkPersistentFlagRequired("wgLocalAddr") //nolint
initCmd.MarkPersistentFlagRequired("signalAddr") //nolint
initCmd.MarkPersistentFlagRequired("stunURLs") //nolint
initCmd.MarkPersistentFlagRequired("turnURLs") //nolint
}
// generateKey generates a new Wireguard private key

View File

@ -10,6 +10,7 @@ import (
)
const (
// ExitSetupFailed defines exit code
ExitSetupFailed = 1
)
@ -38,6 +39,7 @@ func init() {
rootCmd.AddCommand(signalCmd)
}
// SetupCloseHandler handles SIGTERM signal and exits with success
func SetupCloseHandler() {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
@ -46,10 +48,11 @@ func SetupCloseHandler() {
os.Exit(0)
}
// InitLog parses and sets log-level input
func InitLog(logLevel string) {
level, err := log.ParseLevel(logLevel)
if err != nil {
log.Errorf("efailed parsing log-level %s: %s", logLevel, err)
log.Errorf("Failed parsing log-level %s: %s", logLevel, err)
os.Exit(ExitSetupFailed)
}
log.SetLevel(level)