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

Local check runner #51

Merged
merged 95 commits into from
Sep 19, 2023
Merged

Local check runner #51

merged 95 commits into from
Sep 19, 2023

Conversation

dmichaels-harvard
Copy link
Contributor

@dmichaels-harvard dmichaels-harvard commented Jul 16, 2023

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.

@dmichaels-harvard dmichaels-harvard requested review from SooLee, netsettler and willronchetti and removed request for SooLee July 17, 2023 13:52
Copy link
Member

@willronchetti willronchetti left a 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

@@ -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):
Copy link
Member

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?

Comment on lines +519 to +550
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"))
Copy link
Member

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):
Copy link
Member

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:
Copy link
Member

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
Copy link
Member

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

@dmichaels-harvard dmichaels-harvard merged commit 314bd7c into master Sep 19, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants