Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stacker/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def isstr(s):
elif isinstance(root, dict):
result = {}
for k, v in root.items():
result[k] = substitute_references(v, environment, exp, full_exp)
new_k = substitute_references(k, environment, exp, full_exp)
result[new_k] = substitute_references(v, environment, exp, full_exp)
return result
elif isstr(root):
# Strings are the special type where all substitutions happen. If we
Expand Down
4 changes: 3 additions & 1 deletion stacker/lookups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ def extract_lookups(value):

"""
lookups = set()

if isinstance(value, basestring):
lookups = lookups.union(extract_lookups_from_string(value))
elif isinstance(value, list):
for v in value:
lookups = lookups.union(extract_lookups(v))
elif isinstance(value, dict):
for v in value.values():
for k, v in value.items():
lookups = lookups.union(extract_lookups(k))
lookups = lookups.union(extract_lookups(v))
return lookups
3 changes: 3 additions & 0 deletions stacker/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def test_render_yaml(self):
substr: prefix-${str_1}-suffix
multiple: ${str_1}-${str_2}
dont_match_this: ${output something}
key_dict:
${namespace}: foo
"""
env = """
namespace: test
Expand Down Expand Up @@ -108,6 +110,7 @@ def test_render_yaml(self):
self.assertEquals(pc['substr'], 'prefix-another str-suffix')
self.assertEquals(pc['multiple'], 'another str-hello')
self.assertEquals(pc['dont_match_this'], '${output something}')
self.assertEquals(pc['key_dict']["test"], 'foo')

def test_render_yaml_errors(self):
# We shouldn't be able to substitute an object into a string
Expand Down
7 changes: 7 additions & 0 deletions stacker/tests/test_lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ def test_lookups_dict(self):
})
self.assertEqual(len(lookups), 1)

# Lookups should work in keys as well.
lookups = extract_lookups({
"${output fakeStack::FakeKeyName}-something": "${output fakeStack::FakeOutput}",
"other": "value",
})
self.assertEqual(len(lookups), 2)

def test_lookups_mixed(self):
lookups = extract_lookups({
"something": "${output fakeStack::FakeOutput}",
Expand Down