From 2b2815507e947d1b030b7989d241545f8d5754bc Mon Sep 17 00:00:00 2001 From: Justin Ryburn Date: Fri, 9 Feb 2024 13:15:34 -0600 Subject: [PATCH] Lint cleanup --- plugins/event_source/kentik_webhook.py | 20 ++++++++++++-------- rulebooks/kentik_alert_example_rule.yml | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/event_source/kentik_webhook.py b/plugins/event_source/kentik_webhook.py index d2f15f8..eab93f7 100644 --- a/plugins/event_source/kentik_webhook.py +++ b/plugins/event_source/kentik_webhook.py @@ -56,7 +56,9 @@ async def webhook(request: web.Request) -> web.Response: try: payload = await request.json() except json.JSONDecodeError as exc: - logger.warning("Wrong body request: failed to decode JSON payload: %s", exc) + logger.warning( + "Wrong body request: failed to decode JSON payload: %s", exc + ) raise web.HTTPBadRequest(text="Invalid JSON payload") from None headers = dict(request.headers) headers.pop("Authorization", None) @@ -84,10 +86,11 @@ def set_app_attr(args: dict[str, Any]) -> dict[str, Any]: Args containing the host and port """ - if "host" not in args: - host = "0.0.0.0" - if "port" not in args: - port = 5000 + # Not really used since the values are fed in from the main. + # if "host" not in args: + # host = "0.0.0.0" + # if "port" not in args: + # port = 5000 app_attrs = {} app_attrs["host"] = args.get("host") app_attrs["port"] = args.get("port") @@ -135,7 +138,8 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: await runner.cleanup() if __name__ == "__main__": - """MockQueue if running directly.""" + # MockQueue is used if running directly + # via python and not part of an Ansible rulebook. class MockQueue: """A fake queue.""" @@ -148,8 +152,8 @@ async def put(self: "MockQueue", event: dict) -> None: main( MockQueue(), { - "host": "localhost", - "port": 80, + "host": "0.0.0.0", + "port": 5000, }, ), ) diff --git a/rulebooks/kentik_alert_example_rule.yml b/rulebooks/kentik_alert_example_rule.yml index dc6ddeb..6dc603f 100644 --- a/rulebooks/kentik_alert_example_rule.yml +++ b/rulebooks/kentik_alert_example_rule.yml @@ -15,7 +15,7 @@ - name: Print out the alert condition: event.i == 1 - ## Define the action we should take should the condition be met + ## Define the action we should take should the condition be met action: run_playbook: