chore(userspace/falco): move output config struct one level up

Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
This commit is contained in:
Leonardo Grasso
2020-09-24 15:22:45 +02:00
committed by poiana
parent 6451a55d82
commit 57c62ba6a7
5 changed files with 22 additions and 21 deletions

View File

@@ -52,7 +52,7 @@ void falco_configuration::init(list<string> &cmdline_options)
{
init_cmdline_options(cmdline_options);
falco::outputs::output::config stdout_output;
falco::outputs::config stdout_output;
stdout_output.name = "stdout";
m_outputs.push_back(stdout_output);
}
@@ -81,7 +81,7 @@ void falco_configuration::init(string conf_filename, list<string> &cmdline_optio
m_json_output = m_config->get_scalar<bool>("json_output", false);
m_json_include_output_property = m_config->get_scalar<bool>("json_include_output_property", true);
falco::outputs::output::config file_output;
falco::outputs::config file_output;
file_output.name = "file";
if(m_config->get_scalar<bool>("file_output", "enabled", false))
{
@@ -99,21 +99,21 @@ void falco_configuration::init(string conf_filename, list<string> &cmdline_optio
m_outputs.push_back(file_output);
}
falco::outputs::output::config stdout_output;
falco::outputs::config stdout_output;
stdout_output.name = "stdout";
if(m_config->get_scalar<bool>("stdout_output", "enabled", false))
{
m_outputs.push_back(stdout_output);
}
falco::outputs::output::config syslog_output;
falco::outputs::config syslog_output;
syslog_output.name = "syslog";
if(m_config->get_scalar<bool>("syslog_output", "enabled", false))
{
m_outputs.push_back(syslog_output);
}
falco::outputs::output::config program_output;
falco::outputs::config program_output;
program_output.name = "program";
if(m_config->get_scalar<bool>("program_output", "enabled", false))
{
@@ -131,7 +131,7 @@ void falco_configuration::init(string conf_filename, list<string> &cmdline_optio
m_outputs.push_back(program_output);
}
falco::outputs::output::config http_output;
falco::outputs::config http_output;
http_output.name = "http";
if(m_config->get_scalar<bool>("http_output", "enabled", false))
{
@@ -159,7 +159,7 @@ void falco_configuration::init(string conf_filename, list<string> &cmdline_optio
m_grpc_cert_chain = m_config->get_scalar<string>("grpc", "cert_chain", "/etc/falco/certs/server.crt");
m_grpc_root_certs = m_config->get_scalar<string>("grpc", "root_certs", "/etc/falco/certs/ca.crt");
falco::outputs::output::config grpc_output;
falco::outputs::config grpc_output;
grpc_output.name = "grpc";
// gRPC output is enabled only if gRPC server is enabled too
if(m_config->get_scalar<bool>("grpc_output", "enabled", true) && m_grpc_enabled)

View File

@@ -37,7 +37,7 @@ public:
{
m_path = path;
YAML::Node config;
std::vector<falco::outputs::output::config> outputs;
std::vector<falco::outputs::config> outputs;
try
{
m_root = YAML::LoadFile(path);
@@ -196,7 +196,7 @@ public:
bool m_json_output;
bool m_json_include_output_property;
std::string m_log_level;
std::vector<falco::outputs::output::config> m_outputs;
std::vector<falco::outputs::config> m_outputs;
uint32_t m_notifications_rate;
uint32_t m_notifications_max_burst;

View File

@@ -87,7 +87,7 @@ void falco_outputs::init(bool json_output,
m_initialized = true;
}
void falco_outputs::add_output(falco::outputs::output::config oc)
void falco_outputs::add_output(falco::outputs::config oc)
{
falco::outputs::output *oo;

View File

@@ -31,7 +31,6 @@ limitations under the License.
// falco output engine. The falco rules engine is implemented by a
// separate class falco_engine.
//
class falco_outputs : public falco_common
{
public:
@@ -44,10 +43,10 @@ public:
bool time_format_iso_8601, std::string hostname,
const std::string& alternate_lua_dir);
void add_output(falco::outputs::output::config oc);
void add_output(falco::outputs::config oc);
//
// ev is an event that has matched some rule. Pass the event
// evt is an event that has matched some rule. Pass the event
// to all configured outputs.
//
void handle_event(gen_event *evt, std::string &rule, std::string &source,

View File

@@ -27,6 +27,16 @@ namespace falco
namespace outputs
{
//
// The way to refer to an output (file, syslog, stdout, etc.)
// An output has a name and set of options.
//
struct config
{
std::string name;
std::map<std::string, std::string> options;
};
//
// This class acts as the primary interface for implementing
// a Falco output class.
@@ -35,14 +45,6 @@ namespace outputs
class output
{
public:
// The way to refer to an output (file, syslog, stdout, etc.)
// An output has a name and set of options.
struct config
{
std::string name;
std::map<std::string, std::string> options;
};
void init(config oc, bool buffered,
bool time_format_iso_8601, std::string hostname)
{