Skip to content

Commit

Permalink
Add missing error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender committed Apr 30, 2022
1 parent 815d102 commit f494c27
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"strings"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -40,9 +41,18 @@ func init() {
rootCmd.PersistentFlags().StringVar(&maxmindDBPath, "maxmind-db-path", "", "Path to the maxmind database file")
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "How verbose the logs should be. panic, fatal, error, warn, info, debug, trace")

viper.BindPFlag("metrics-port", rootCmd.PersistentFlags().Lookup("metrics-port"))
viper.BindPFlag("maxmind-db-path", rootCmd.PersistentFlags().Lookup("maxmind-db-path"))
viper.BindPFlag("log-level", rootCmd.PersistentFlags().Lookup("log-level"))
err := viper.BindPFlag("metrics-port", rootCmd.PersistentFlags().Lookup("metrics-port"))
if err != nil {
log.Fatalln(err.Error())
}
err = viper.BindPFlag("maxmind-db-path", rootCmd.PersistentFlags().Lookup("maxmind-db-path"))
if err != nil {
log.Fatalln(err.Error())
}
err = viper.BindPFlag("log-level", rootCmd.PersistentFlags().Lookup("log-level"))
if err != nil {
log.Fatalln(err.Error())
}
}

// initConfig reads in config file and ENV variables if set.
Expand Down

0 comments on commit f494c27

Please sign in to comment.