Merge pull request #1140 from nspcc-dev/feature/config

config: allow to specify config path directly
This commit is contained in:
Roman Khimov 2020-07-03 12:28:30 +03:00 committed by GitHub
commit 2f09ec38fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,11 @@ func (c Config) GenerateUserAgent() string {
// path for the given netMode.
func Load(path string, netMode netmode.Magic) (Config, error) {
configPath := fmt.Sprintf("%s/protocol.%s.yml", path, netMode)
return LoadFile(configPath)
}
// LoadFile loads config from the provided path.
func LoadFile(configPath string) (Config, error) {
if _, err := os.Stat(configPath); os.IsNotExist(err) {
return Config{}, errors.Wrap(err, "Unable to load config")
}