-
Notifications
You must be signed in to change notification settings - Fork 7k
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
CLICKHOUSE-3852: Add ability to set up config parameters from env variables. #2741
Conversation
@@ -103,7 +103,8 @@ static ElementIdentifier getElementIdentifier(Node * element) | |||
{ | |||
const Node * node = attrs->item(i); | |||
std::string name = node->nodeName(); | |||
if (name == "replace" || name == "remove" || name == "incl" || name == "from_zk") | |||
if (name == "replace" || name == "remove" || | |||
std::count(ConfigProcessor::SUBSTITUTION_ATTRS.begin(), ConfigProcessor::SUBSTITUTION_ATTRS.end(), name) > 0) |
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.
A little bit redundant (the loop always till the end).
std::find is probably better.
@@ -267,12 +268,13 @@ void ConfigProcessor::doIncludesRecursive( | |||
return; | |||
} | |||
|
|||
std::vector<const Node *> attr_nodes; |
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.
Maybe std::map keyed by attribute name is better?
XMLDocumentPtr env_document; | ||
auto get_env_node = [&](const std::string & name) -> const Node * | ||
{ | ||
std::string value = std::getenv(name.c_str()); |
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.
We can include cstdlib
explicitly.
XMLDocumentPtr env_document; | ||
auto get_env_node = [&](const std::string & name) -> const Node * | ||
{ | ||
std::string value = std::getenv(name.c_str()); |
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 getenv() function returns a pointer to the value in the environment, or NULL if there is no match.
Possible initialization of std::string from nullptr.
At least we need a test that something works. |
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en