Skip to content

Commit

Permalink
Add --check-config flag to only check config validity
Browse files Browse the repository at this point in the history
Fixes #493
  • Loading branch information
jacksontj committed Aug 16, 2023
1 parent 1063ec6 commit f032b91
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/promxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func init() {
}

type cliOpts struct {
Version bool `long:"version" short:"v" description:"print out version and exit"`
Version bool `long:"version" short:"v" description:"print out version and exit"`
CheckConfig bool `long:"check-config" description:"check config files and exit"`

BindAddr string `long:"bind-addr" description:"address for promxy to listen on" default:":8082"`
ConfigFile string `long:"config" description:"path to the config file" default:"config.yaml"`
Expand Down Expand Up @@ -174,6 +175,15 @@ func main() {
os.Exit(0)
}

// CheckConfig simply will load the config, check for errors, and exit
if opts.CheckConfig {
if _, err := proxyconfig.ConfigFromFile(opts.ConfigFile); err != nil {
logrus.Fatalf("Error loading cfg: %v", err)
}
fmt.Printf("%s if valid promxy config file syntax\n", opts.ConfigFile)
os.Exit(0)
}

logging.SetMaxFormPrefix(opts.LogMaxFormPrefix)

// Use log level
Expand Down

0 comments on commit f032b91

Please sign in to comment.