Merge pull request #5027 from kevpar/config-check

Improve error detection when loading config
This commit is contained in:
Maksym Pavlenko 2021-02-10 14:37:31 -08:00 committed by GitHub
commit 88d97362b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,9 +114,15 @@ can be used and modified as necessary as a custom configuration.`
config = defaultConfig()
)
if err := srvconfig.LoadConfig(context.GlobalString("config"), config); err != nil && !os.IsNotExist(err) {
// Only try to load the config if it either exists, or the user explicitly
// told us to load this path.
configPath := context.GlobalString("config")
_, err := os.Stat(configPath)
if !os.IsNotExist(err) || context.GlobalIsSet("config") {
if err := srvconfig.LoadConfig(configPath, config); err != nil {
return err
}
}
// Apply flags to the config
if err := applyFlags(context, config); err != nil {