-
Notifications
You must be signed in to change notification settings - Fork 136
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
new: Support specifying complex list arguments as JSON #578
Conversation
@@ -463,10 +463,54 @@ def _add_args_post_put(self, parser) -> List[Tuple[str, str]]: | |||
|
|||
return list_items | |||
|
|||
def _validate_parent_child_conflicts(self, parsed: argparse.Namespace): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally wanted to implement this validation using argparse's mutually exclusive groups but I couldn't get it to play nicely with multiple compatible fields.
if v is None: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't specific to this change but should address some weird errors I was running into.
extensions.append("nullable") | ||
|
||
if arg.is_parent: | ||
extensions.append("conflicts with children") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if I like the wording here, any suggestions would be much appreciated!
398a7f6
to
a55023c
Compare
I noticed that a VLAN is used in the interfaces of the instance creation command so VPC creation in step 1 is probably not necessary? |
Oops, you're right. I think I copied it from another PR description and forgot to remove it lol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Unit test and manual test passed locally!
However, I'm seeing a couple of similar errors when running the integration tests around put operations, i.e.
> exec_test_command(BASE_CMD + ["put", str(file_path), bucket_name])
This failed when assert the process.retruncode:
> assert process.returncode == 0
Not sure if it's related to this PR or a interim issue, but as a heads up. I'm looking into it as well.
Nice find, I'll look into this as well! |
@zliang-akamai Looks like they're failing on my end too, I'll take a quick look |
So it looks like supporting dicts as JSON introduces some weird multi-parent conflicts with commands that nest complex lists in dicts (e.g. Firewalls). Given the main use-case of this feature is to reduce complexity when specifying complex lists of objects, I'll remove dicts as JSON from the scope of this PR 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integration test passed! Nice work 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally. Nice work!
📝 Description
This change adds support for specifying complex lists (e.g.
interfaces
) as a single JSON string rather than a series of arguments. This should improve the UX when writing scripts that may use these complex structures.This pull request also makes various changes to generalize parent/child logic rather than explicitly relating it to lists.
This PR originally included improvements to the command help pages but I decided to break it out into a separate PR because of how big this PR was getting 🙂
✔️ How to Test
The following test steps assume you have pulled down this PR and run
make install
.Integration Testing
Unit Testing
Manual Testing
Complex Lists as JSON
interfaces
argument defined as JSON: