Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix file handler lookups with pseudo parameters #239

Merged
merged 2 commits into from
Oct 16, 2016
Merged
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
2 changes: 1 addition & 1 deletion stacker/lookups/handlers/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def handler(value, **kwargs):


def parameterized_codec(raw, b64):
pattern = re.compile(r'{{(\w+)}}')
pattern = re.compile(r'{{([::|\w]+)}}')

parts = []
s_index = 0
Expand Down
15 changes: 14 additions & 1 deletion stacker/tests/lookups/handlers/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,24 @@ def test_handler_parameterized(self):
self.assertEqual(troposphere.GenericHelperFn, type(out))

def test_handler_parameterized_b64(self):
expected = 'Hello, world'
expected = 'Regular text {{Psuedo::Var}} {{RegVar}} {{Non-Var}}'
processed = {
'Fn::Base64': {
'Fn::Join': [
'',
['Regular text ',
{'Ref': 'Psuedo::Var'},
' ',
{'Ref': 'RegVar'},
' {{Non-Var}}']
]
}
}
with mock.patch('stacker.lookups.handlers.file.read_value_from_path',
return_value=expected):
out = handler('parameterized-b64:file://tmp/test')
self.assertEqual(troposphere.Base64, type(out))
self.assertEqual(processed, out.data)

def test_unknown_codec(self):
expected = 'Hello, world'
Expand Down