Skip to content

Commit

Permalink
Fixed a problem where there was no recursive parsing within the step …
Browse files Browse the repository at this point in the history
…and it fails if the plan has irregular list of lists. #221
  • Loading branch information
eerkunt committed Feb 25, 2020
1 parent 4fc58f4 commit f2f772f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# CHANGELOG

## 1.1.9 (2020-02-25)
* Fixed a problem where a property within the terraform plan fails to get parsed if it is list of lists. ([#221](https://github.com/eerkunt/terraform-compliance/issues/221))

## 1.1.8 (2020-02-23)
* Fixed a problem where tags are not recognised on Auto-Scaling Groups due to different key/pair structure within the terraform. ([#208](https://github.com/eerkunt/terraform-compliance/issues/208))


## 1.1.7 (2020-02-06)
* Fixed a case where resource referencing fails when the output is coming from a module and does not registered in terraform plan.

Expand Down
8 changes: 6 additions & 2 deletions terraform_compliance/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,11 @@ def its_key_is_not_value(_step_obj, key, value):
@when(u'it has {something:ANY}')
@when(u'it contains {something:ANY}')
@then(u'it must contain {something:ANY}')
def it_condition_contain_something(_step_obj, something):
def it_condition_contain_something(_step_obj, something, inherited_values=Null):
prop_list = []

_step_obj.context.stash = inherited_values if inherited_values is not Null else _step_obj.context.stash

if _step_obj.context.type in ('resource', 'data'):
for resource in _step_obj.context.stash:
if not isinstance(resource, dict) \
Expand Down Expand Up @@ -315,6 +317,8 @@ def it_condition_contain_something(_step_obj, something):
found_key = found_key[0]
found_value = value.get('value')
break
elif isinstance(value, list):
found_key, found_value = it_condition_contain_something(_step_obj, something, value)

if found_key is not Null and len(found_key):
found_key = found_key[0] if len(found_key) == 1 else found_key
Expand All @@ -338,7 +342,7 @@ def it_condition_contain_something(_step_obj, something):
if prop_list:
_step_obj.context.stash = prop_list
_step_obj.context.property_name = something
return True
return something, prop_list

if _step_obj.state != Step.State.FAILED:
skip_step(_step_obj,
Expand Down

0 comments on commit f2f772f

Please sign in to comment.