-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add the ability to parse zebrad.toml config file #485
Conversation
I also needed to remove a test, since it sends in a string as the config file contents (rather than a filename), and the toml parser doesn't support that. But this test did very little, and we won't miss it. If reviewers prefer, I could restore the test and have it create a file, actually it could create both a |
c1e2852
to
3c1229b
Compare
frontend/rpc_client.go
Outdated
} | ||
} | ||
|
||
func connFromIni(confPath string) (*rpcclient.ConnConfig, error) { | ||
cfg, err := ini.Load(confPath) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to read config file: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, fmt.Errorf("failed to read config file: %w", err) | |
return nil, fmt.Errorf("failed to read config file in .conf format: %w", err) |
frontend/rpc_client.go
Outdated
} | ||
_, err := toml.DecodeFile(confPath, &tomlConf) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to read config file: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, fmt.Errorf("failed to read config file: %w", err) | |
return nil, fmt.Errorf("failed to read config file in .toml format: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK with minor suggestion for the error messages.
2fb4e33
to
6800d6e
Compare
Fixes zcash#462. If the file extension is .conf (as in zcash.conf), then parse the file as an INI file. If the extension is .toml (as in zebrad.toml), then interpret as TOML.
6800d6e
to
b2efbdc
Compare
Force pushed to implement review comments (thanks, Daira), and force pushed to rebase. |
Fixes #462. If the file extension is
.conf
(as inzcash.conf
), then parse the file as an INI file (as is done today). If the extension is.toml
(as inzebrad.toml
), then interpret as TOML. The only possible problem is if the user has specified a toml config file (using--zcash-conf-path
) that doesn't have the.toml
extension. It will then be interpreted as a.conf
(INI) file. But it's not unreasonable to require the toml extension.