Add config validation option (#306)
authorDmitriy Lukyanchikov <31628587+dmitriy-lukyanchikov@users.noreply.github.com>
Sun, 1 Apr 2018 09:20:41 +0000 (12:20 +0300)
committerBrian Brazil <brian.brazil@robustperception.io>
Sun, 1 Apr 2018 09:20:41 +0000 (10:20 +0100)
main.go

diff --git a/main.go b/main.go
index e0d586f68022548359751d0d95a491de92f16e15..3520301b3b94179c40b578868582f84dc672d8e7 100644 (file)
--- a/main.go
+++ b/main.go
@@ -49,6 +49,7 @@ var (
        configFile    = kingpin.Flag("config.file", "Blackbox exporter configuration file.").Default("blackbox.yml").String()
        listenAddress = kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests.").Default(":9115").String()
        timeoutOffset = kingpin.Flag("timeout-offset", "Offset to subtract from timeout in seconds.").Default("0.5").Float64()
+       configCheck   = kingpin.Flag("config.check", "If true validate the config file and then exit.").Default().Bool()
 
        Probers = map[string]prober.ProbeFn{
                "http": prober.ProbeHTTP,
@@ -217,6 +218,12 @@ func main() {
                level.Error(logger).Log("msg", "Error loading config", "err", err)
                os.Exit(1)
        }
+
+       if *configCheck {
+               level.Info(logger).Log("msg", "Config file is ok exiting...")
+               os.Exit(0)
+       }
+
        level.Info(logger).Log("msg", "Loaded config file")
 
        hup := make(chan os.Signal)