Documentation
¶
Index ¶
- Constants
- func BindPFlags(flags *pflag.FlagSet, section string)
- func InitConfig(userProvidedCfgFile, instance string, flags *pflag.FlagSet) (string, error)
- func Reset()
- func SetDefaultConfDirs(dirs []string)
- func SetDefaultConfName(name string)
- func SetFlags(instance string, flags *pflag.FlagSet) error
Constants ¶
const ( DefaultConfDir = "/etc/aerospike" DefaultConfName = "astools" )
Variables ¶
This section is empty.
Functions ¶
func BindPFlags ¶
BindPFlags binds the flags to viper. Should be called after the flag set is created. The section is prepended to the flag name to create the viper key. For example, if the config is found under the "cluster" section then we will bind "cluster.host" to the flag "host". If the section is empty then the flag name is used as the key.
func InitConfig ¶
InitConfig reads in config file and ENV variables if set. Should be called from the root commands PersistentPreRunE function with the flags of the current command.
func Reset ¶
func Reset()
Reset resets the global configToFlagMap and viper instance. Should be called before or after tests that use InitConfig or BindPFlags. If using testify suites call it in the SetupTest function and or SetupSubTests if using suite.T().Run(...).
func SetDefaultConfDirs ¶
func SetDefaultConfDirs(dirs []string)
SetConfDirs sets the directories to search for the config file when a file name is not explicitly provided. If a file name is explicitly provided viper checks both relative and absolute file paths.
func SetDefaultConfName ¶
func SetDefaultConfName(name string)
SetConfName sets the name of the config file to search for. For aerospike tools this is astools but for asvec it is asvec.
Types ¶
This section is empty.