Skip to content
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

feat: add config verify flag #1814

Merged
merged 5 commits into from
Jan 13, 2025

Conversation

PeterChen13579
Copy link
Collaborator

fixes #1806

@PeterChen13579 PeterChen13579 changed the title feature: add config verify flag feat: add config verify flag Jan 8, 2025
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 40.00000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 71.53%. Comparing base (36a9f40) to head (4dd6125).
Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
src/main/Main.cpp 0.00% 10 Missing ⚠️
src/app/VerifyConfig.hpp 58.33% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1814      +/-   ##
===========================================
+ Coverage    71.40%   71.53%   +0.12%     
===========================================
  Files          315      322       +7     
  Lines        13113    13235     +122     
  Branches      6683     6737      +54     
===========================================
+ Hits          9363     9467     +104     
+ Misses        1965     1945      -20     
- Partials      1785     1823      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -47,6 +47,7 @@ CliArgs::parse(int argc, char const* argv[])
("conf,c", po::value<std::string>()->default_value(kDEFAULT_CONFIG_PATH), "configuration file")
("ng-web-server,w", "Use ng-web-server")
("migrate", po::value<std::string>(), "start migration helper")
("verify", "Checks the validity of config values")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this flag should take path to config as well?

Copy link
Collaborator Author

@PeterChen13579 PeterChen13579 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to verify config currently user should run command clio_server -c ./config.json --verify, right?
I was thinking that maybe clio_server --verify ./config.json may be better, but maybe it doesn't matter.
@godexsoft, WDYT?

src/main/Main.cpp Outdated Show resolved Hide resolved
src/util/newconfig/ConfigDefinition.hpp Outdated Show resolved Hide resolved
src/main/Main.cpp Outdated Show resolved Hide resolved
cindyyan317
cindyyan317 previously approved these changes Jan 13, 2025
Copy link
Collaborator

@cindyyan317 cindyyan317 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the unittests. LGTM

@PeterChen13579 PeterChen13579 merged commit f1698c5 into XRPLF:develop Jan 13, 2025
17 checks passed
@@ -47,6 +47,7 @@ CliArgs::parse(int argc, char const* argv[])
("conf,c", po::value<std::string>()->default_value(kDEFAULT_CONFIG_PATH), "configuration file")
("ng-web-server,w", "Use ng-web-server")
("migrate", po::value<std::string>(), "start migration helper")
("verify", "Checks the validity of config values")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to verify config currently user should run command clio_server -c ./config.json --verify, right?
I was thinking that maybe clio_server --verify ./config.json may be better, but maybe it doesn't matter.
@godexsoft, WDYT?

return EXIT_FAILURE;
[](app::CliArgs::Action::VerifyConfig const& verify) {
if (app::verifyConfig(verify.configPath)) {
std::cout << "Config is correct" << "\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to print config path here, something like

Config './config.json` is correct


auto const json = ConfigFileJson::makeConfigFileJson(configPath);
if (!json.has_value()) {
std::cerr << json.error().error << std::endl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a bit more verbose:

std::cerr << "Error parsing json from config: " << configPath << "\n" << json.error().error << std::endl;

}
auto const errors = gClioConfig.parse(json.value());
if (errors.has_value()) {
for (auto const& err : errors.value())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the same here:

std::cerr << "Issues found in provided config '" << configPath << "':\n" ;

Comment on lines +212 to +218
// used to Verify Config test
static constexpr auto kVALID_JSON_DATA = R"JSON({
"server": {
"ip": "0.0.0.0",
"port": 51233
}
})JSON";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the file where it is used.

PeterChen13579 added a commit that referenced this pull request Jan 13, 2025
@PeterChen13579
Copy link
Collaborator Author

@kuznetsss The verify flag can work both with and without the -c. ie clio_server -c ./config.json --verify and clio_server --verify ./config.json or clio_server ./config.json --verify all works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config Validation command
3 participants