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 10, 2024
1 parent 9878921 commit 1f15245
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 @@ -19,18 +19,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 1f15245

Please sign in to comment.