-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Capture blacklisted specs inside archive (#3664)
* Capture the name of blacklisted specs, and dump them to a file in the archive. * Added parser and spec to parse the blacklisted specs and use in rules. Signed-off-by: Ryan Blakley <[email protected]>
- Loading branch information
1 parent
045878f
commit da20d33
Showing
11 changed files
with
135 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.. automodule:: insights.parsers.blacklisted | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import re | ||
|
||
|
||
BLACKLISTED_SPECS = [] | ||
_FILE_FILTERS = set() | ||
_COMMAND_FILTERS = set() | ||
_PATTERN_FILTERS = set() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
BlacklistedSpecs - File ``blacklisted_specs.txt`` | ||
================================================= | ||
""" | ||
from insights.core import JSONParser | ||
from insights.core.plugins import parser | ||
from insights.specs import Specs | ||
|
||
|
||
@parser(Specs.blacklisted_specs) | ||
class BlacklistedSpecs(JSONParser): | ||
""" | ||
Parses the blacklisted_specs.txt file generated on archive creation. | ||
Typical output:: | ||
"{"specs": ["insights.specs.default.DefaultSpecs.dmesg", "insights.specs.default.DefaultSpecs.fstab"]}" | ||
Attributes: | ||
specs (list): List of blacklisted specs. | ||
Examples: | ||
>>> type(specs) | ||
<class 'insights.parsers.blacklisted.BlacklistedSpecs'> | ||
>>> result = ['insights.specs.default.DefaultSpecs.dmesg', 'insights.specs.default.DefaultSpecs.fstab'] | ||
>>> specs.specs == result | ||
True | ||
""" | ||
@property | ||
def specs(self): | ||
return self.data['specs'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import doctest | ||
import pytest | ||
|
||
from insights.core.exceptions import SkipComponent | ||
from insights.parsers import blacklisted | ||
from insights.parsers.blacklisted import BlacklistedSpecs | ||
from insights.tests import context_wrap | ||
|
||
|
||
SPECS = '{"specs": ["insights.specs.default.DefaultSpecs.dmesg", "insights.specs.default.DefaultSpecs.fstab"]}' | ||
|
||
|
||
def test_blacklisted_doc_examples(): | ||
env = { | ||
"specs": BlacklistedSpecs(context_wrap(SPECS)), | ||
} | ||
failed, total = doctest.testmod(blacklisted, globs=env) | ||
assert failed == 0 | ||
|
||
|
||
def test_skip(): | ||
with pytest.raises(SkipComponent) as ex: | ||
BlacklistedSpecs(context_wrap("")) | ||
assert "Empty output." in str(ex) | ||
|
||
|
||
def test_blacklist_specs(): | ||
bs = BlacklistedSpecs(context_wrap(SPECS)) | ||
assert bs.specs[0] == "insights.specs.default.DefaultSpecs.dmesg" |