[ https://issues.apache.org/jira/browse/MINIFICPP-273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16226927#comment-16226927 ]
ASF GitHub Bot commented on MINIFICPP-273: ------------------------------------------ Github user achristianson commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/162#discussion_r148019697 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -698,6 +703,34 @@ void YamlConfiguration::checkRequiredField(YAML::Node *yamlNode, const std::stri } } +YAML::Node YamlConfiguration::getOptionalField(YAML::Node *yamlNode, + const std::string &fieldName, + const YAML::Node &defaultValue, + const std::string &yamlSection, + const std::string &providedInfoMessage) { + std::string infoMessage = providedInfoMessage; + auto result = yamlNode->as<YAML::Node>()[fieldName]; + if (!result) { + if (infoMessage.empty()) { + // Build a helpful info message for the user to inform them that a default is being used + infoMessage = + yamlNode->as<YAML::Node>()["name"] ? + "Using default value for optional field '" + fieldName + "' in component named '" + + yamlNode->as<YAML::Node>()["name"].as<std::string>() + "'" : + "Using default value for optional field '" + fieldName + "' "; + if (!yamlSection.empty()) { + infoMessage += " [in '" + yamlSection + "' section of configuration file]: "; + } + + infoMessage += defaultValue.as<std::string>(); + } + logger_->log_info(infoMessage.c_str()); + result = defaultValue; --- End diff -- My bad. Will fix & re-push. I didn't notice any issues in make linter, though. > Simplify configuration by supporting default values for scheduling strategy > and period > -------------------------------------------------------------------------------------- > > Key: MINIFICPP-273 > URL: https://issues.apache.org/jira/browse/MINIFICPP-273 > Project: NiFi MiNiFi C++ > Issue Type: Improvement > Reporter: Andrew Christianson > Assignee: Andrew Christianson > Priority: Minor > > Simplify configuration of MiNiFi - C++ by allowing default values for > scheduling strategy and period. -- This message was sent by Atlassian JIRA (v6.4.14#64029)