-
Notifications
You must be signed in to change notification settings - Fork 0
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
Local check runner #51
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to remove/mark the old script as deprecated
foursight_core/check_utils.py
Outdated
@@ -360,7 +362,7 @@ def get_grouped_check_results(self, connection): | |||
grouped_list = [group for group in grouped_results.values()] | |||
return sorted(grouped_list, key=lambda v: v['_name']) | |||
|
|||
def run_check_or_action(self, connection, check_str, check_kwargs): | |||
def obsolete_run_check_or_action(self, connection, check_str, check_kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going to rename you may as well remove?
Info = namedtuple("CheckInfo", ["kind", | ||
"is_check", | ||
"is_action", | ||
"name", | ||
"qualified_name", | ||
"file", | ||
"line", | ||
"module", | ||
"unqualified_module", | ||
"package", | ||
"github_url", | ||
"args", | ||
"kwargs", | ||
"function", | ||
"associated_action", | ||
"associated_check"]) | ||
return Info(info["kind"], | ||
info["kind"] == "check", | ||
info["kind"] == "action", | ||
info["name"], | ||
qualified_check_or_action_name(info["name"], info["module"]), | ||
info["file"], | ||
info["line"], | ||
info["module"], | ||
unqualified_module_name(info["module"]), | ||
info["package"], | ||
info["github_url"], | ||
info["args"], | ||
info["kwargs"], | ||
info["function"], | ||
info.get("action"), | ||
info.get("check")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really serve any purpose if you're not going to use outside of this function? You might consider moving this somewhere it can be used more widely ie: helper function that builds.
_original_stderr = sys.stderr | ||
|
||
@contextmanager | ||
def captured_output(capture: bool = True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a good candidate for utils
return aws_credentials_name | ||
|
||
|
||
def confirm_interactively(message: str, exit_if_no: bool = False) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have code very similar to this in 4dn-cloud-infra you could also bring into utils ie: arg_utils ?
pyproject.toml
Outdated
@@ -1,6 +1,6 @@ | |||
[tool.poetry] | |||
name = "foursight-core" | |||
version = "4.4.0" | |||
version = "4.4.0.1b1" # TODO: To become 4.4.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would definitely consider minor version here
Command-line (poetry) script (local-check-runner) to run checks locally, so people don't have to cobble together their own. Usage looks like this: local-check-runner access_key_expiration_detection/access_key_status ... to run this check. If you want to run any associated action after the check runs then specify the --action option. Can also list all known checks. Went to some care to ensure a lot of seeming garbage logging is not output to confuse/confound the user.