diff --git a/userspace/falco/configuration.cpp b/userspace/falco/configuration.cpp index 2748f62f..a179fa27 100644 --- a/userspace/falco/configuration.cpp +++ b/userspace/falco/configuration.cpp @@ -84,8 +84,8 @@ falco_configuration::falco_configuration(): m_metrics_convert_memory_to_mb(true), m_metrics_include_empty_values(false), m_container_engines_mask(0), - m_container_engines_cri_socket_paths({"/run/containerd/containerd.sock", "/run/crio/crio.sock","/run/k3s/containerd/containerd.sock"}), - m_container_engines_disable_cri_async(false) + m_container_engines_disable_cri_async(false), + m_container_engines_cri_socket_paths({"/run/containerd/containerd.sock", "/run/crio/crio.sock","/run/k3s/containerd/containerd.sock"}) { m_config_schema = nlohmann::json::parse(schema_json_string); } @@ -749,5 +749,12 @@ void falco_configuration::set_cmdline_option(const std::string &opt) throw std::logic_error("Error parsing config option \"" + opt + "\". Must be of the form key=val or key.subkey=val"); } - m_config.set_scalar(keyval.first, keyval.second); + if (keyval.second[0] == '{' && keyval.second[keyval.second.size() - 1] == '}') + { + YAML::Node node = YAML::Load(keyval.second); + m_config.set_object(keyval.first, node); + } else + { + m_config.set_scalar(keyval.first, keyval.second); + } } diff --git a/userspace/falco/yaml_helper.h b/userspace/falco/yaml_helper.h index af38b194..d1134873 100644 --- a/userspace/falco/yaml_helper.h +++ b/userspace/falco/yaml_helper.h @@ -177,6 +177,16 @@ public: node = value; } + /** + * Set the node identified by key to an object value + */ + void set_object(const std::string& key, const YAML::Node& value) + { + YAML::Node node; + get_node(node, key, true); + node = value; + } + /** * Get the sequence value from the node identified by key. */ @@ -482,5 +492,6 @@ namespace YAML { return true; } + // The "encode" function is not needed here, in fact you can simply YAML::load any json string. }; }