config: Make fs.ConfigFileGet return an exists flag
This commit is contained in:
+14
-1
@@ -82,7 +82,7 @@ var (
|
||||
|
||||
func init() {
|
||||
// Set the function pointer up in fs
|
||||
fs.ConfigFileGet = FileGet
|
||||
fs.ConfigFileGet = FileGetFlag
|
||||
}
|
||||
|
||||
func getConfigData() *goconfig.ConfigFile {
|
||||
@@ -1108,6 +1108,19 @@ func Authorize(args []string) {
|
||||
fs.Config(name)
|
||||
}
|
||||
|
||||
// FileGetFlag gets the config key under section returning the
|
||||
// the value and true if found and or ("", false) otherwise
|
||||
//
|
||||
// It looks up defaults in the environment if they are present
|
||||
func FileGetFlag(section, key string) (string, bool) {
|
||||
newValue, err := getConfigData().GetValue(section, key)
|
||||
if err == nil {
|
||||
return newValue, true
|
||||
}
|
||||
envKey := fs.ConfigToEnv(section, key)
|
||||
return os.LookupEnv(envKey)
|
||||
}
|
||||
|
||||
// FileGet gets the config key under section returning the
|
||||
// default or empty string if not set.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user