Skip to content

Commit

Permalink
Add debug flag for log level
Browse files Browse the repository at this point in the history
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>
  • Loading branch information
vatsalparekh committed Sep 27, 2024
1 parent a261149 commit e9af3f1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@ import (
var (
masterURL string
kubeconfigFile string
debug bool
)

func init() {
flag.StringVar(&kubeconfigFile, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flag.BoolVar(&debug, "debug", false, "Variable to set log level to debug; default is false")
flag.Parse()
}

func main() {
// set up signals so we handle the first shutdown signal gracefully
ctx := signals.SetupSignalContext()

if debug {
logrus.SetLevel(logrus.DebugLevel)
logrus.Debugf("Loglevel set to [%v]", logrus.DebugLevel)
}

// This will load the kubeconfig file in a style the same as kubectl
cfg, err := kubeconfig.GetNonInteractiveClientConfig(kubeconfigFile).ClientConfig()
if err != nil {
Expand Down

0 comments on commit e9af3f1

Please sign in to comment.