-
Notifications
You must be signed in to change notification settings - Fork 785
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
Node configuration auto updater #4579
Conversation
std::istringstream stream_current (current_str); | ||
std::string line_defaults, line_current, result; | ||
|
||
while (std::getline (stream_defaults, line_defaults) && std::getline (stream_current, line_current)) |
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.
This loop will only work correctly if the defaults and current lists are sorted and have the same number of elements. Is this guranteed to happen? If yes, how do you know?
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.
The current list and default list will always follow the exact same layout. This is because we use the serialize_toml function to create the configs. That function will create all the tree nodes, config items, and docs based on the input
The algorithm converts the structured data in plain text and then does the comparison. |
A test case would be nice. |
Unfortunately the TOML library will only write all key/value lines as uncommented line entries. So even if we merge the TOML trees we still have to compare the final string output to the default string output to find what lines should be commented (default values) |
@dsiganos I have added a unit test |
@@ -1038,3 +1038,47 @@ TEST (toml, log_config_no_required) | |||
|
|||
ASSERT_FALSE (toml.get_error ()) << toml.get_error ().get_message (); | |||
} | |||
|
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.
I think in this case, a systest would had been a better option.
But you have done it now...
This pull request introduces a new command line feature
--update_config
, which updates the nodes current configuration by merging custom settings into the latest configuration template. Custom settings will be uncommented in the new configuration, while default values will be commented.This feature simplifies the process for node operators to maintain an up-to-date configuration without manually merging the current configuration with the new one.
Features:
Limitations: