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

CLICKHOUSE-3852: Add ability to set up config parameters from env variables. #2741

Merged
merged 4 commits into from
Jul 29, 2018

Conversation

alesapin
Copy link
Member

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

@@ -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)
Copy link
Member

@alexey-milovidov alexey-milovidov Jul 27, 2018

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;
Copy link
Member

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());
Copy link
Member

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());
Copy link
Member

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.

@alexey-milovidov
Copy link
Member

At least we need a test that something works.

@alexey-milovidov alexey-milovidov merged commit 79607b9 into ClickHouse:master Jul 29, 2018
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.

2 participants