-
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
Change How App Templates Are Updated for sam init
#1678
Conversation
Possible challenge - no escape hatch to NOT update if not desired. Could be worth a larger refactor.
Hold on this PR, going for a deeper approach. |
Unit and integ tests still need to be updated, but this change allows us to drop the prompt to update app templates, and will safely handle edge cases that previously required us to prompt on, for example, updated.
Separates into two logical submethods. Still need to completely overhaul init unit and integ tests as a result of the change to the user flow.
…wood45/aws-sam-cli into update-in-non-interactive-init
Also, black formatting updates.
New tests cover most of this ground, and integ tests definitely do. Removing tests with side effects.
Too long for linter
sam init
) | ||
# Now we need to delete the old repo and move this one. | ||
try: |
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.
Suggestion: can we move this try except block which is inside another try except block to another method, helps with readability.
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 in new version.
click.echo("WARN: Could not clone app template repo.") | ||
|
||
def _clone_new_app_templates(self, shared_dir, expected_path): | ||
with osutils.mkdir_temp(ignore_errors=True) as tempdir: |
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.
if we are using ignore_errors, i also suggest we add a callback for onerror
to log a debug message.
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 in latest change
self.clone_attempted = True | ||
|
||
def _template_directory_exists(self, expected_path): | ||
path = Path(expected_path) |
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.
nit/non-blocking: I notice we are using both pathlib and os.path, is it possible to standardize on one or other.
This was initially triggered by a need to support silent updates for the IDEs using
--no-interactive
as an option for init. To properly handle that, while still handling cases where a user might have issues copying the new init templates down for some reason (internet connections, possibly file permissions), this PR now changes our general approach for copying app templates.Now, we use a sort of state machine logic - we use a temp directory to stage the
git clone
of the app templates repo, deleting and copying over the new repo as appropriate to the AWS SAM shared directory. If the clone fails, no change is made and the existing app templates copy is preserved.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.