From 3543225683919975614b7a9db644a380e1634cfd Mon Sep 17 00:00:00 2001 From: Rafid Aslam Date: Tue, 24 Oct 2023 19:53:48 +0700 Subject: [PATCH] terraform_plan/action: Support "*" resource type For including all of the resource types --- src/tirith/providers/terraform_plan/handler.py | 2 +- tests/providers/terraform_plan/test_action.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/providers/terraform_plan/test_action.py diff --git a/src/tirith/providers/terraform_plan/handler.py b/src/tirith/providers/terraform_plan/handler.py index 39b5afd..4408e49 100644 --- a/src/tirith/providers/terraform_plan/handler.py +++ b/src/tirith/providers/terraform_plan/handler.py @@ -118,7 +118,7 @@ def provide(provider_inputs, input_data): resource_type = provider_inputs["terraform_resource_type"] is_resource_type_found = False for resource_change in resource_changes: - if resource_change["type"] == resource_type: + if resource_type in (resource_change["type"], "*"): is_resource_type_found = True for action in resource_change["change"]["actions"]: outputs.append( diff --git a/tests/providers/terraform_plan/test_action.py b/tests/providers/terraform_plan/test_action.py new file mode 100644 index 0000000..5609242 --- /dev/null +++ b/tests/providers/terraform_plan/test_action.py @@ -0,0 +1,9 @@ +from tirith.providers.terraform_plan import handler +from utils import load_terraform_plan_json + + +def test_action_star_resource_type_should_include_every_resource_types(): + provider_args_dict = {"operation_type": "action", "terraform_resource_type": "*"} + result = handler.provide(provider_args_dict, load_terraform_plan_json("input_implicit_elb_secgroup.json")) + + assert len(result) == 4