Merge pull request #5732 from tstromberg/config-avail

Hide innocuous viper ConfigFileNotFoundError
pull/5736/head
Thomas Strömberg 2019-10-25 12:45:20 -07:00 committed by GitHub
commit 991d84e9f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -235,9 +235,11 @@ func initConfig() {
configPath := localpath.ConfigFile
viper.SetConfigFile(configPath)
viper.SetConfigType("json")
err := viper.ReadInConfig()
if err != nil {
glog.Warningf("Error reading config file at %s: %v", configPath, err)
if err := viper.ReadInConfig(); err != nil {
// This config file is optional, so don't emit errors if missing
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
glog.Warningf("Error reading config file at %s: %v", configPath, err)
}
}
setupViper()
}