-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Deploy off aws cli #1455
Deploy off aws cli #1455
Conversation
43ce53c
to
bbf1cca
Compare
The number of commits appear huge, but thats because this is based off This is still very much in WIP. |
samcli/lib/deploy/deployer.py
Outdated
@@ -140,7 +155,8 @@ def create_changeset( | |||
LOG.debug("Unable to create changeset", exc_info=ex) | |||
raise ex | |||
|
|||
def describe_changeset(self, change_set_id, stack_name): | |||
@pprint(format_string=DESCRIBE_CHANGESET_FORMAT_STRING, format_kwargs=DESCRIBE_CHANGESET_DEFAULT_ARGS) |
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.
click based decorator to create a table.
- Not breaking parameter overrides formats - still requires refactoring and error handling
- needs refactoring
- wire up command.py for `sam deploy` - move deploy specific exceptions to inherit from UserException
- `sam deploy` now has tables while showcasing the changeset and showcasing events happening during deploy.
- fixed unit tests - linting fixes - doc strings - further unit tests and integration tests need to be added.
bd1dc60
to
787b270
Compare
- exercise all command line parameters for `aws` and `sam`
value = [value] | ||
|
||
while state.rargs and not next_option: | ||
for prefix in self._nargs_parser.prefixes: |
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.
Do we have or intend to support any commands where there is a trailing argument that does not have a prefix?
For example, many CLIs have a valid command that works much like the following:
cli commandname --option-one A --option-set B C D --input inputfile.txt outputfile.txt
(Where outputfile.txt is a positional argument that goes at the end of the full command.)
This code would appear to assume we never allow for that pattern. Is this a correct assumption for us?
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.
True, one way to codify that would be to add such positional argument to the front of the command. I'm not sure if there are alternate ways to check for unbounded number of arguments for a given option without a breaking change though.
samcli/commands/deploy/command.py
Outdated
"change set. Specify this flag if you want to view your stack changes" | ||
"before executing the change set. The command creates an AWS CloudForma-" | ||
"tion change set and then exits without executing the change set. After" | ||
"you view the change set, execute it to implement your changes.", |
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.
Execute it how? We should make that clear somewhere, probably here.
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.
will clarify this.
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.
done
samcli/lib/deploy/deployer.py
Outdated
""" | ||
try: | ||
resp = self._client.describe_stacks(StackName=stack_name) | ||
if len(resp["Stacks"]) != 1: |
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'd actually check that this is equal to zero.
I believe (could be wrong) that certain situations and inputs can lead this number to be greater than one. At the very least, the API documentation lists this as a possibility.
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'm looking at this as a defensive programming POV - I don't think the logic below needs to change.
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.
changed.
@awood45 addressed your comments. |
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.
One comment to verify before merging.
@@ -69,7 +69,7 @@ def has_stack(self, stack_name): | |||
""" | |||
try: | |||
resp = self._client.describe_stacks(StackName=stack_name) | |||
if len(resp["Stacks"]) != 1: | |||
if not resp["Stacks"]: |
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.
Does this handle an empty array?
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.
Actually, better question, can we ensure that we test the case of no such stack? Just to be sure for regressions.
self.assertEqual(self.deployer._client, self.cloudformation_client) | ||
self.assertEqual(self.deployer.changeset_prefix, "samcli-cloudformation-package-deploy-") | ||
|
||
def test_deployer_has_no_stack(self): |
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.
Example of such a test, @awood45
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.
Most comments are minor, something to think about. Just make sure the table formatting doesn't lead to zeros or infinities or crashes. We don't want deploy to crash because of the table print.
samcli/lib/deploy/deployer.py
Outdated
try: | ||
outputs = stacks_description["Stacks"][0]["Outputs"] | ||
if echo: | ||
click.secho("\nStack {stack_name} outputs:\n".format(stack_name=stack_name)) |
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.
Can you not use click
in this layer? It adds a dependency on click for this module to function. It makes the code less portable.
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.
done
usable_width_no_margin = int(width) - 1 | ||
usable_width = int((usable_width_no_margin - (margin if margin else min_margin))) | ||
|
||
width_per_column = int(usable_width / total_args) |
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.
- Can this be zero?
- Can this be infinity?
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.
added ValueError if so.
- add retries - more regression testing - remove types for capabilities
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.
Thank you for making the changes. This looks good to me.
|
||
def _check_stack_complete(self, status): | ||
return "COMPLETE" in status and "CLEANUP" not in status | ||
|
||
def wait_for_execute(self, stack_name, changeset_type): | ||
|
||
click.secho("\nWaiting for stack create/update to complete\n") | ||
sys.stdout.write("\nWaiting for stack create/update to complete\n") |
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.
Are you sure these are written to stdout in AWS CLI?
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.
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.
+1 add flushes
- show cases Add, Modify, Delete with +, * and -
* feat: sam deploy without aws cli pre-installed - Not breaking parameter overrides formats - still requires refactoring and error handling * feat: new click types for deploy parameters * feat: show changeset and stack events - needs refactoring * refactor: move deploy classes to lib - wire up command.py for `sam deploy` - move deploy specific exceptions to inherit from UserException * rebase: latest from `sam package` port * feat: decorator for printing tables - `sam deploy` now has tables while showcasing the changeset and showcasing events happening during deploy. * fix: wrap text on resource status column on `sam deploy` - fixed unit tests - linting fixes - doc strings - further unit tests and integration tests need to be added. * fix: cleaner text formatting for tables * tests: add unit tests for full suite of `sam deploy` * tests: add integration tests for `sam deploy` * tests: regression test suite for `sam deploy` - exercise all command line parameters for `aws` and `sam` * fix: deploy command now showcases stack outputs * fix: address comments * fix: return stack outputs from `get_stack_outputs` * fix: width margins on table prints * fix: address comments - add retries - more regression testing - remove types for capabilities * tests: tests for pprint of tables * usability: add table headers - show cases Add, Modify, Delete with +, * and -
* feat: sam deploy without aws cli pre-installed - Not breaking parameter overrides formats - still requires refactoring and error handling * feat: new click types for deploy parameters * feat: show changeset and stack events - needs refactoring * refactor: move deploy classes to lib - wire up command.py for `sam deploy` - move deploy specific exceptions to inherit from UserException * rebase: latest from `sam package` port * feat: decorator for printing tables - `sam deploy` now has tables while showcasing the changeset and showcasing events happening during deploy. * fix: wrap text on resource status column on `sam deploy` - fixed unit tests - linting fixes - doc strings - further unit tests and integration tests need to be added. * fix: cleaner text formatting for tables * tests: add unit tests for full suite of `sam deploy` * tests: add integration tests for `sam deploy` * tests: regression test suite for `sam deploy` - exercise all command line parameters for `aws` and `sam` * fix: deploy command now showcases stack outputs * fix: address comments * fix: return stack outputs from `get_stack_outputs` * fix: width margins on table prints * fix: address comments - add retries - more regression testing - remove types for capabilities * tests: tests for pprint of tables * usability: add table headers - show cases Add, Modify, Delete with +, * and -
Clean output of stack events as deploy progress
Clean output of changeset before beginning the deploy process
Port from AWS CLI
Unit tests added
Integration tests added
Regression tests added
Write Design Document (Do I need to write a design document?)
Write unit tests
Write/update functional tests
Write/update integration tests
make pr
passesWrite documentation
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.