Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: new custom filter 'fstab_mounted.dirs' to ls_lan spec #4255

Merged
merged 14 commits into from
Nov 7, 2024

Conversation

TZ3070
Copy link
Contributor

@TZ3070 TZ3070 commented Oct 17, 2024

All Pull Requests:

Check all that apply:

  • Have you followed the guidelines in our Contributing document, including the instructions about commit messages?
  • No Sensitive Data in this change?
  • Is this PR to correct an issue?
  • Is this PR an enhancement?

Complete Description of Additions/Changes:

  • add a special filter keyword fstab_mounted.dirs to the ls_lan spec
    it's not a real directory existing in any system, but a switch like keyword,
    to enable the ls_lan_dirs to involve the mounted points in the default /etc/fstab
    configuration file as the ls -lan candidates.

@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.14%. Comparing base (5c68edd) to head (03d352f).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4255   +/-   ##
=======================================
  Coverage   77.14%   77.14%           
=======================================
  Files         762      762           
  Lines       41476    41483    +7     
  Branches     8763     8765    +2     
=======================================
+ Hits        31997    32004    +7     
+ Misses       8422     8421    -1     
- Partials     1057     1058    +1     
Flag Coverage Δ
unittests 77.13% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xiangce xiangce added parser new spec SPEC Change needs SPEC approval and removed new spec labels Oct 17, 2024
Xinting Li added 3 commits November 4, 2024 14:33
Signed-off-by: Xinting Li <[email protected]>
Signed-off-by: Xinting Li <[email protected]>
Signed-off-by: xintli <[email protected]>
Copy link
Contributor

@xiangce xiangce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check my comments to the relevant Jira card.

Signed-off-by: xintli <[email protected]>
xintli added 6 commits November 5, 2024 15:18
Signed-off-by: xintli <[email protected]>
Signed-off-by: xintli <[email protected]>
Signed-off-by: xintli <[email protected]>
Signed-off-by: xintli <[email protected]>
Signed-off-by: xintli <[email protected]>
fix
Signed-off-by: xintli <[email protected]>
insights/specs/datasources/ls.py Outdated Show resolved Hide resolved
insights/specs/datasources/ls.py Outdated Show resolved Hide resolved
insights/specs/datasources/ls.py Outdated Show resolved Hide resolved
insights/tests/datasources/test_ls.py Outdated Show resolved Hide resolved
@@ -241,6 +241,10 @@
enabled: true
- name: insights.components.selinux.SELinuxEnabled
enabled: true

# needed for the 'ls lan' spec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better explain it a bit clearer, e.g. needed for the 'spec.fstab_mounted' to the 'ls_lan' spec

return _list_items(Specs.ls_lan_dirs)
filters = _list_items(Specs.ls_lan_dirs)
if 'specs.fstab_mounted' in filters and FSTab in broker:
filter_list = filters.split()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a redundant operation, better update the _list_items and let it return a sorted list instead. (you may want to update all other datasources to join the new value returned by _list_items

filter_list = filters.split()
for mntp in broker[FSTab].mounted_on.keys():
mnt_point = os.path.dirname(mntp)
filter_list.extend([mnt_point] if mnt_point and mnt_point not in filter_list else [])
Copy link
Contributor

@xiangce xiangce Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declear the filter_list as a set first to avoid duplicate element in nature.

filter_list = set(_list_items(Specs.ls_lan_dirs)) # assume the _list_items returns `list` here already
for mntp in broker[FSTab].mounted_on.keys():
    filter_list.add(os.path.dirname(mntp))
...
return ' '.join(filter_list)

Signed-off-by: xintli <[email protected]>
Signed-off-by: xintli <[email protected]>
Copy link
Collaborator

@JoySnow JoySnow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM !

Signed-off-by: xintli <[email protected]>
@xiangce xiangce changed the title FEAT: Add new parser LsFSTab FEAT: new custom filter to ls_lan spec Nov 7, 2024
@xiangce xiangce changed the title FEAT: new custom filter to ls_lan spec FEAT: new custom filter 'fstab_mounted.dirs' to ls_lan spec Nov 7, 2024
@xiangce xiangce merged commit 2c292ce into RedHatInsights:master Nov 7, 2024
12 checks passed
xiangce pushed a commit that referenced this pull request Nov 7, 2024
xiangce pushed a commit that referenced this pull request Nov 14, 2024
Signed-off-by: Xinting Li <[email protected]>
(cherry picked from commit 2c292ce)
(cherry picked from commit ba3819d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser SPEC Change needs SPEC approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants