Skip to content

Commit

Permalink
new(libsinsp): print LIST() in markdown format for list fields
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <luca@guerra.sh>
  • Loading branch information
LucaGuerra committed Oct 1, 2024
1 parent aeb8793 commit c6e512f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions userspace/libsinsp/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -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 {

Check warning on line 686 in userspace/libsinsp/filter.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/filter.cpp#L686

Added line #L686 was not covered by tests
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;

Expand Down Expand Up @@ -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()) {
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c6e512f

Please sign in to comment.