From 6a0df223f61506b95998d25aa07ca7da26d86c42 Mon Sep 17 00:00:00 2001 From: Luca Guerra Date: Tue, 1 Oct 2024 15:27:42 +0000 Subject: [PATCH] new(libsinsp): print LIST() in markdown format for list fields Signed-off-by: Luca Guerra --- userspace/libsinsp/filter.cpp | 16 ++++++++++++++-- userspace/libsinsp/filter.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/userspace/libsinsp/filter.cpp b/userspace/libsinsp/filter.cpp index 07abbed7a9..4dfc5ea203 100644 --- a/userspace/libsinsp/filter.cpp +++ b/userspace/libsinsp/filter.cpp @@ -660,6 +660,10 @@ sinsp_filter_factory::check_infos_to_fieldclass_infos( info.tags.insert("ARG_ALLOWED"); } + if(fld->m_flags & EPF_IS_LIST) { + info.tags.insert("EPF_IS_LIST"); + } + cinfo.fields.emplace_back(std::move(info)); } @@ -679,6 +683,10 @@ bool sinsp_filter_factory::filter_field_info::is_deprecated() const { return (tags.find("EPF_DEPRECATED") != tags.end()); } +bool sinsp_filter_factory::filter_field_info::is_list() const { + return (tags.find("EPF_IS_LIST") != tags.end()); +} + uint32_t sinsp_filter_factory::filter_fieldclass_info::s_rightblock_start = 30; uint32_t sinsp_filter_factory::filter_fieldclass_info::s_width = 120; @@ -740,8 +748,12 @@ std::string sinsp_filter_factory::filter_fieldclass_info::as_markdown( continue; } - os << "`" << fld_info.name << "` | " << fld_info.data_type << " | " << fld_info.desc - << std::endl; + std::string data_type = fld_info.data_type; + if(fld_info.is_list()) { + data_type = "LIST(" + data_type + ")"; + } + + os << "`" << fld_info.name << "` | " << data_type << " | " << fld_info.desc << std::endl; } if(deprecated_count == fields.size()) { diff --git a/userspace/libsinsp/filter.h b/userspace/libsinsp/filter.h index 9a3661ea6e..8d3bbaaf7b 100644 --- a/userspace/libsinsp/filter.h +++ b/userspace/libsinsp/filter.h @@ -112,6 +112,7 @@ class sinsp_filter_factory { bool is_skippable() const; bool is_deprecated() const; + bool is_list() const; }; // Describes a group of filtercheck fields ("ka")