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

Cast to correct types for list-structure(list-scalar, scalar) #776

Merged
merged 2 commits into from
May 14, 2014

Conversation

danielgtaylor
Copy link
Contributor

This modifies the shorthand JSON parsing to make sure a list of structures
are cast to the correct types based on the service model. Previously they
would all be set as strings, for example with EMR:

$ aws emr modify-instance-groups --instance-groups InstanceGroupId=foo,InstanceCount=3

Invalid value ('3') for param element of list:InstanceGroups of type list

In the above, the 3 was parsed as a string rather than an integer. This
update uses unpack_scalar_cli_arg to fix the issue by casting to the proper
types.

Please review @jamesls.

This modifies the shorthand JSON parsing to make sure a list of structures
are cast to the correct types based on the service model. Previously they
would all be set as strings, for example with EMR:

```
$ aws emr modify-instance-groups --instance-groups InstanceGroupId=foo,InstanceCount=3

Invalid value ('3') for param element of list:InstanceGroups of type list
```

In the above, the `3` was parsed as a string rather than an integer. This
update uses `unpack_scalar_cli_arg` to fix the issue by casting to the proper
types.
arg_types = {}
for arg in param.members.members:
# Arg name -> arg object lookup
args[arg.name] = arg
# Arg name -> arg type lookup
arg_types[arg.name] = arg.type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both args and arg_types. If we're storing the whole object could we just use args[name].type instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - I'll update it.

@jamesls
Copy link
Member

jamesls commented May 14, 2014

:shipit:

danielgtaylor added a commit that referenced this pull request May 14, 2014
Cast to correct types for list-structure(list-scalar, scalar). Fixes #776.
@danielgtaylor danielgtaylor merged commit 9de9d09 into aws:develop May 14, 2014
@danielgtaylor danielgtaylor deleted the shorthand-unpack branch May 14, 2014 22:35
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this pull request Feb 12, 2022
This command currently prints version information in JSON format.
In future we will expand this to print everything from versions of
dependencies, list of commands available, capabilities exposed by
the commands, etc. Hopefully eventually this will provide a nice
list of machine readable instructions for other tools to integrate
with SAM CLI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants