Skip to content

Commit

Permalink
feat: support line filter in spec Cleaner
Browse files Browse the repository at this point in the history
- RHINENG-14668
  for each filter, keep 10k matched lines by default for now.
  don't remove the "grep -F" as it's faster and can be used
  to reduce the file size before cleaning
- Add test to verify the count of matched lines
  Move all spec relevant tests to tests/specs
  Move all core relevant tests to tests/core

Signed-off-by: Xiangce Liu <[email protected]>
  • Loading branch information
xiangce committed Dec 27, 2024
1 parent 721cb83 commit d5c77bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion insights/core/spec_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _filter_line_per_allowlist(self, line, allow_info):
# stop checking it when enough lines contain the key were found
allow_info.pop(a_key) if allow_info[a_key] == 0 else None
return line
# discard line when none filters found
# discard the line when all filters are enough matched

def get_obfuscate_functions(self, filename='', no_obfuscate=None):
"""
Expand Down
7 changes: 7 additions & 0 deletions insights/core/spec_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def _clean_content(self):
# Cleaning - Entry
if cleans:
log.debug("Cleaning (%s) %s", "/".join(cleans), self.relative_path)
allowlist = None
content = self.cleaner.clean_content(
content[::-1], # Scan from bottom
allowlist=allowlist,
Expand Down Expand Up @@ -313,7 +314,10 @@ def create_args(self):
"""
args = []
if self._filters:
<<<<<<< HEAD
log.debug("Pre-filtering %s", self.relative_path)
=======
>>>>>>> 19ecd79e (feat: support line filter in spec Cleaner)
args.append(["grep", "-F", "\n".join(self._filters), self.path])

return args
Expand Down Expand Up @@ -435,7 +439,10 @@ def create_args(self):
command = [shlex.split(self.cmd)]

if self.split and self._filters:
<<<<<<< HEAD
log.debug("Pre-filtering %s", self.relative_path)
=======
>>>>>>> 19ecd79e (feat: support line filter in spec Cleaner)
command.append(["grep", "-F", "\n".join(self._filters)])

return command
Expand Down

0 comments on commit d5c77bb

Please sign in to comment.