1
0
mirror of https://github.com/aquasecurity/kube-bench.git synced 2024-11-22 16:18:07 +00:00

Allow config file to be specified on the command line

This commit is contained in:
Liz Rice 2017-06-22 15:34:21 +01:00
parent 96364e3f29
commit 0d6d3a03ef

View File

@ -71,17 +71,17 @@ func init() {
"", "",
`Run all the checks under this comma-delimited list of groups. Example --group="1.1"`, `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. // initConfig reads in config file and ENV variables if set.
func initConfig() { func initConfig() {
if cfgFile != "" { // enable ability to specify config file via flag if cfgFile != "" { // enable ability to specify config file via flag
viper.SetConfigFile(cfgFile) viper.SetConfigFile(cfgFile)
} } else {
viper.SetConfigName("config") // name of config file (without extension) viper.SetConfigName("config") // name of config file (without extension)
viper.AddConfigPath(cfgDir) // adding home directory as first search path viper.AddConfigPath(cfgDir) // adding ./cfg as first search path
}
viper.SetEnvPrefix("CISK8S") viper.SetEnvPrefix("CISK8S")
viper.AutomaticEnv() // read in environment variables that match viper.AutomaticEnv() // read in environment variables that match