returnnil,fmt.Errorf("unable to check if %s is a file. Error: %v",customConf,err)
}
ifisFile{
iferr:=cfg.Append(customConf);err!=nil{
returnnil,fmt.Errorf("failed to load custom conf '%s': %v",customConf,err)
}
newFile=false
}
}
ifnewFile&&!allowEmpty{
returnnil,fmt.Errorf("unable to find configuration file: %q, please ensure you are running in the correct environment or set the correct configuration file with -c",CustomConf)
}
ifextraConfig!=""{
iferr:=cfg.Append([]byte(extraConfig));err!=nil{
returnnil,fmt.Errorf("unable to append more config: %v",err)
log.Error("Unable to check if %s is a file. Error: %v",customConf,err)
}
ifisFile{
iferr:=cfg.Append(customConf);err!=nil{
log.Fatal("Failed to load custom conf '%s': %v",customConf,err)
}
}elseif!allowEmpty{
log.Fatal("Unable to find configuration file: %q.\nEnsure you are running in the correct environment or set the correct configuration file with -c.",CustomConf)
}// else: no config file, a config file might be created at CustomConf later (might not)
ifextraConfig!=""{
iferr=cfg.Append([]byte(extraConfig));err!=nil{
log.Fatal("Unable to append more config: %v",err)
}
}
cfg.NameMapper=ini.SnackCase
returncfg
}
// LoadCommonSettings loads common configurations from a configuration provider.