feat(checks): Exclude checks with -e/--exclude-checks

* feat(checks): Select checks to run

* feat(checks): Include tests

* feat(checks): Exclude checks with -e

* fix(checks): Include missing path

* fix(checks): Include comments
This commit is contained in:
Pepe Fagoaga
2022-06-16 12:57:36 +02:00
committed by GitHub
parent 9d5e43e6a2
commit 8abcc5988d
5 changed files with 49 additions and 12 deletions

View File

@@ -8,6 +8,12 @@ from lib.logger import logger
from lib.outputs import report
# Exclude checks to run
def exclude_checks_to_run(checks_to_execute, excluded_checks):
for check in excluded_checks:
checks_to_execute.discard(check)
return checks_to_execute
# Parse checks from file
def parse_checks_from_file(checks_file):
checks_to_execute = set()
@@ -27,7 +33,7 @@ def parse_checks_from_file(checks_file):
def load_checks_to_execute(checks_file, check_list, provider):
checks_to_execute = set()
# LOADER
# Handle if there are checks passed using -c/--checks
if check_list:
for check_name in check_list:
@@ -35,11 +41,8 @@ def load_checks_to_execute(checks_file, check_list, provider):
# Handle if there are checks passed using -C/--checks-file
elif checks_file:
# check if file exists or path
# check permissions to read
try:
checks_to_execute = parse_checks_from_file(checks_file)
except Exception as e:
logger.error(f"{checks_file}: {e.__class__.__name__}")
@@ -52,7 +55,7 @@ def load_checks_to_execute(checks_file, check_list, provider):
# Format: "providers.{provider}.services.{service}.{check_name}.{check_name}"
check_name = check_module.split(".")[-1]
checks_to_execute.add(check_name)
print(checks_to_execute)
return checks_to_execute