Skip to content

Commit

Permalink
Merge pull request #310 from kddejong/Fix/OnlyOneCheck
Browse files Browse the repository at this point in the history
Don't return Ref: AWS::NoValue when doing get_values
  • Loading branch information
kddejong authored Aug 23, 2018
2 parents e775e13 + fea6b57 commit 8457fdd
Show file tree
Hide file tree
Showing 3 changed files with 1,717 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cfnlint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ def get_values(self, obj, key, path=[]):
if isinstance(value, (dict)):
if len(value) == 1:
is_condition = False
is_no_value = False
for obj_key, obj_value in value.items():
if obj_key in cfnlint.helpers.CONDITION_FUNCTIONS:
is_condition = True
Expand All @@ -675,7 +676,9 @@ def get_values(self, obj, key, path=[]):
check_obj = obj.copy()
check_obj[key] = result['Value']
matches.extend(self.get_values(check_obj, key, result['Path']))
if not is_condition:
elif obj_key == 'Ref' and obj_value == 'AWS::NoValue':
is_no_value = True
if not is_condition and not is_no_value:
result = {}
result['Path'] = path[:]
result['Value'] = value
Expand All @@ -690,13 +693,16 @@ def get_values(self, obj, key, path=[]):
if isinstance(list_value, dict):
if len(list_value) == 1:
is_condition = False
is_no_value = False
for obj_key, obj_value in list_value.items():
if obj_key in cfnlint.helpers.CONDITION_FUNCTIONS:
is_condition = True
results = self.get_condition_values(obj_value, path[:] + [list_index, obj_key])
if isinstance(results, list):
matches.extend(results)
if not is_condition:
elif obj_key == 'Ref' and obj_value == 'AWS::NoValue':
is_no_value = True
if not is_condition and not is_no_value:
result = {}
result['Path'] = path[:] + [list_index]
result['Value'] = list_value
Expand Down
Loading

0 comments on commit 8457fdd

Please sign in to comment.