Skip to content

Commit

Permalink
Add new flag "init kubernetes client" (#186)
Browse files Browse the repository at this point in the history
The flag defaults to true, but can be overridden when running in
non-kubernetes environment
  • Loading branch information
damyan authored Sep 24, 2024
1 parent 88523be commit 1183ade
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ import (
)

var (
flagLogFile = flag.StringP("logfile", "l", "", "Name of the log file to append to. Default: stdout/stderr only")
flagLogNoStdout = flag.BoolP("nostdout", "N", false, "Disable logging to stdout/stderr")
flagLogLevel = flag.StringP("loglevel", "L", "info", fmt.Sprintf("Log level. One of %v", getLogLevels()))
flagConfig = flag.StringP("conf", "c", "", "Use this configuration file instead of the default location")
flagPlugins = flag.BoolP("plugins", "P", false, "list plugins")
flagLogFile = flag.StringP("logfile", "l", "", "Name of the log file to append to. Default: stdout/stderr only")
flagLogNoStdout = flag.BoolP("nostdout", "N", false, "Disable logging to stdout/stderr")
flagLogLevel = flag.StringP("loglevel", "L", "info", fmt.Sprintf("Log level. One of %v", getLogLevels()))
flagConfig = flag.StringP("conf", "c", "", "Use this configuration file instead of the default location")
flagPlugins = flag.BoolP("plugins", "P", false, "list plugins")
flagInitKubernetesClient = flag.BoolP("init-kubernetes", "i", true, "init kubernetes client")
)

var logLevels = map[string]func(*logrus.Logger){
Expand Down Expand Up @@ -130,9 +131,11 @@ func main() {
}
}

// initialize kubernetes client
if err := kubernetes.InitClient(); err != nil {
log.Fatalf("Failed to initialize kubernetes client: %v", err)
// initialize kubernetes client, if needed
if *flagInitKubernetesClient {
if err := kubernetes.InitClient(); err != nil {
log.Fatalf("Failed to initialize kubernetes client: %v", err)
}
}

// start server
Expand Down

0 comments on commit 1183ade

Please sign in to comment.