fix(userspace/falco): solve tests issues

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
Jason Dellaluce 2023-01-12 17:38:51 +00:00 committed by poiana
parent 4aefb7fd7d
commit db2f5d5e9c
3 changed files with 27 additions and 12 deletions

View File

@ -20,17 +20,31 @@ using namespace falco::app;
application::run_result application::load_config()
{
try
{
if (!m_options.conf_filename.empty())
{
m_state->config->init(m_options.conf_filename, m_options.cmdline_config_options);
falco_logger::set_time_format_iso_8601(m_state->config->m_time_format_iso_8601);
}
else
{
m_state->config->init(m_options.cmdline_config_options);
}
}
catch (std::exception& e)
{
return run_result::fatal(e.what());
}
// log after config init because config determines where logs go
falco_logger::set_time_format_iso_8601(m_state->config->m_time_format_iso_8601);
falco_logger::log(LOG_INFO, "Falco version: " + std::string(FALCO_VERSION) + " (" + std::string(FALCO_TARGET_ARCH) + ")\n");
if (!m_state->cmdline.empty())
{
falco_logger::log(LOG_DEBUG, "CLI args: " + m_state->cmdline);
}
if (!m_options.conf_filename.empty())
{
falco_logger::log(LOG_INFO, "Falco initialized with configuration file: " + m_options.conf_filename + "\n");
}

View File

@ -159,8 +159,6 @@ bool application::init(int argc, char **argv, std::string &errstr)
m_state->cmdline += *arg;
}
// initialize default config with cmdline overrides (-o option)
m_state->config->init(m_options.cmdline_config_options);
m_initialized = true;
return true;
}

View File

@ -318,9 +318,12 @@ void falco_configuration::load_yaml(const std::string& config_name, const yaml_h
std::list<falco_configuration::plugin_config> plugins;
try
{
if (config.is_defined("plugins"))
{
config.get_sequence<std::list<falco_configuration::plugin_config>>(plugins, string("plugins"));
}
}
catch (exception &e)
{
// Might be thrown due to not being able to open files