From 0d6d3a03ef9e24b9fdfc4d959450e1a5c4a00023 Mon Sep 17 00:00:00 2001
From: Liz Rice <liz@lizrice.com>
Date: Thu, 22 Jun 2017 15:34:21 +0100
Subject: [PATCH] Allow config file to be specified on the command line

---
 cmd/root.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/root.go b/cmd/root.go
index bd8a832..da8ab94 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -71,18 +71,18 @@ func init() {
 		"",
 		`Run all the checks under this comma-delimited list of groups. Example --group="1.1"`,
 	)
-
+	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./cfg/config.yaml)")
 }
 
 // initConfig reads in config file and ENV variables if set.
 func initConfig() {
 	if cfgFile != "" { // enable ability to specify config file via flag
 		viper.SetConfigFile(cfgFile)
+	} else {
+		viper.SetConfigName("config") // name of config file (without extension)
+		viper.AddConfigPath(cfgDir)   // adding ./cfg as first search path
 	}
 
-	viper.SetConfigName("config") // name of config file (without extension)
-	viper.AddConfigPath(cfgDir)   // adding home directory as first search path
-
 	viper.SetEnvPrefix("CISK8S")
 	viper.AutomaticEnv() // read in environment variables that match
 
-- 
GitLab