Skip to content

Commit

Permalink
fixed tf array parameters (#219)
Browse files Browse the repository at this point in the history
Co-authored-by: edgar poce <eponce@onica.com>
  • Loading branch information
edgarpoce and edgar poce authored Apr 6, 2020
1 parent 1b3e5f0 commit 8f0ee9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion runway/module/terraform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Terraform module."""
import copy
import json
import logging
import os
import re
Expand Down Expand Up @@ -189,7 +190,7 @@ def update_env_vars_with_tf_var_values(os_env_vars, tf_vars):
for (nestedkey, nestedval) in val.items()])
)
elif isinstance(val, list):
os_env_vars["TF_VAR_%s" % key] = '[' + ','.join(val) + ']'
os_env_vars["TF_VAR_%s" % key] = json.dumps(val)
else:
os_env_vars["TF_VAR_%s" % key] = val
return os_env_vars
Expand Down
4 changes: 2 additions & 2 deletions tests/module/test_terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_update_env_vars_with_tf_var_values(self):
env_vars = update_env_vars_with_tf_var_values(
{},
{'foo': 'bar',
'list': ['test1', 'test2', 'test3'],
'list': ['foo', 1, True],
'map': {'one': 'two',
'three': 'four'}}
)
Expand All @@ -25,6 +25,6 @@ def test_update_env_vars_with_tf_var_values(self):
# 'TF_VAR_map': '{ one = "two", three = "four" }'}
# )
self.assertTrue(env_vars['TF_VAR_foo'] == 'bar')
self.assertTrue(env_vars['TF_VAR_list'] == '[test1,test2,test3]')
self.assertTrue(env_vars['TF_VAR_list'] == '["foo", 1, true]')
self.assertRegexpMatches(env_vars['TF_VAR_map'], r'one = "two"') # noqa pylint: disable=deprecated-method
self.assertRegexpMatches(env_vars['TF_VAR_map'], r'three = "four"') # noqa pylint: disable=deprecated-method

0 comments on commit 8f0ee9f

Please sign in to comment.