Skip to content

Commit

Permalink
Handle file:// values containing leading/trailing spaces
Browse files Browse the repository at this point in the history
Fixes #631.  The issue was that shorthand processing was triggered
because we were looking at leading spaces instead of the first non
space character.
  • Loading branch information
jamesls committed Feb 7, 2014
1 parent 0877312 commit 0fca1a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion awscli/argprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_parse_method_for_param(self, param, value=None):
if isinstance(value, list):
check_val = value[0]
else:
check_val = value
check_val = value.strip()
if isinstance(check_val, str) and check_val.startswith(('[', '{')):
LOG.debug("Param %s looks like JSON, not considered for "
"param shorthand.", param.py_name)
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/elb/test_register_instances_with_load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def test_two_instance_from_file(self):
cmdline += ' --instances file://%s' % data_path
self.assert_params_for_cmd(cmdline, TWO_INSTANCE_EXPECTED)

def test_json_file_with_spaces(self):
data_path = os.path.join(os.path.dirname(__file__),
'test_with_spaces.json')
cmdline = self.prefix
cmdline += ' --load-balancer-name my-lb'
cmdline += ' --instances file://%s' % data_path
self.assert_params_for_cmd(cmdline, TWO_INSTANCE_EXPECTED)

def test_two_instance_shorthand(self):
cmdline = self.prefix
cmdline += ' --load-balancer-name my-lb'
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/elb/test_with_spaces.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[{"InstanceId": "i-12345678"},
{"InstanceId": "i-87654321"}]

0 comments on commit 0fca1a8

Please sign in to comment.