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

Add --latest flag to restore-snapshot command, fixes #1886, fixes #1163 #2724

Merged
merged 15 commits into from Jan 10, 2021

Conversation

cmuench
Copy link
Collaborator

@cmuench cmuench commented Jan 2, 2021

The Problem/Issue/Bug:

A option to restore the latest snapshot is missing. See #1886 and #1163
Currently we need to pass the name of the latest snapshot as argument.

How this PR Solves The Problem:

Add new --latest flag to restore-snapshot command.
Modify the sort of the app.ListSnapshots method. Sort files by last modification date.
A new method app.GetLatestSnapshot is introduced.

Manual Testing Instructions:

Automated Testing Overview:

Test for command and app GetLatestSnapshot is included.

Release/Deployment notes:

Changes are backwards compatible.

@rfay
Copy link
Member

rfay commented Jan 2, 2021

What do you think about adding --list to this one while you're here as well? The biggest problem with restore-snapshot is figuring out which one, and that would help loads. Autocomplete would help even more, but I don't have a clue how to add non-static autocompletes.

@cmuench
Copy link
Collaborator Author

cmuench commented Jan 2, 2021

@rfay It depends on the concept. We could also add a --restore flag to the snapshot command.

About interaction...
I have a lot experience in building cli application with interaction. I am the maintainer of n98-magerun which is the Magento CLI tool (it's PHP with Symfony Console Component). If we can add readline support it should be possible to have more interaction there. It would be great to select the snapshot if no name is passed. I hope there is a good CLI library in golang for that.

@cmuench
Copy link
Collaborator Author

cmuench commented Jan 2, 2021

@rfay Found that: https://github.com/manifoldco/promptui

@rfay
Copy link
Member

rfay commented Jan 2, 2021

I really think "restore" should have been a subcommand of snapshot in the first place. ddev snaspshot restore [flags]

I guess it would be a fairly easy thing to add that and then remove the restore-snapshot in a year or so.

@cmuench
Copy link
Collaborator Author

cmuench commented Jan 2, 2021

I really think "restore" should have been a subcommand of snapshot in the first place. ddev snaspshot restore [flags]

ok. Let me try that out. I can also try out the promptui there.

@cmuench
Copy link
Collaborator Author

cmuench commented Jan 3, 2021

@rfay I added the sub-command and also the interaction.

The interaction looks really nice:

ddev-restore-snapshot-interactive

Currently the tests are broken. I do not understand where the problem in the build is. Maybe you can have a look on it to give me a hint.

@rfay
Copy link
Member

rfay commented Jan 3, 2021

There were a couple of painful windows test runner failures, but it looks like right now TestGetLatestSnapshot just doesn't work. That should show up with a manual test run in GoLand or running that single test as in https://github.com/drud/ddev/blob/master/docs/developers/building-contributing.md#testing

@cmuench
Copy link
Collaborator Author

cmuench commented Jan 3, 2021

There were a couple of painful windows test runner failures, but it looks like right now TestGetLatestSnapshot just doesn't work. That should show up with a manual test run in GoLand or running that single test as in https://github.com/drud/ddev/blob/master/docs/developers/building-contributing.md#testing

Thanks. Will try it.

@rfay
Copy link
Member

rfay commented Jan 3, 2021

Wow, this terminal library works on Windows in git-bash, PS, and cmd! I've never found one that would do that. We could do so very many things with that!

One nit - restore-snapshot shows up in the list twice when you just type "ddev"

rfay_testpkgmagento2-web___var_www_html

I've reconsidered what I said yesterday, and think we can just move ddev restore-snapshot completely to ddev snapshot restore and leave a hidden restore-snapshot command that just says "please use ddev snapshot restore"

@rfay
Copy link
Member

rfay commented Jan 3, 2021

It's truly lovely.

I don't think the "restore" is properly in there as a subcommand? Because I can't get help for it, ddev snapshot restore -h doesn't get something useful. ddev debug might be a pattern to use.

@cmuench
Copy link
Collaborator Author

cmuench commented Jan 3, 2021

@rfay Everything is committed. Also the new sub-command. Tests are in general "green". There is a download/caching issue in the buildkite/ddev-windows-apache-fpm build job. IMHO it's not related to the changes of the PR.
The previoud failing tests were related to data generated during the test run. I was able to modify the tests so that they are more stable, now.

@rfay
Copy link
Member

rfay commented Jan 3, 2021

Just gave it a quick spin. Looks absolutely fantastic!

@rfay
Copy link
Member

rfay commented Jan 3, 2021

@cmuench do you have CircleCI building on your own account? I see that it's not reporting here.

@cmuench
Copy link
Collaborator Author

cmuench commented Jan 3, 2021

@cmuench do you have CircleCI building on your own account? I see that it's not reporting here.

Did not configure it.

@rfay
Copy link
Member

rfay commented Jan 3, 2021

Weird, I'll chase it. But we sure want that full test. I think what you're doing here would be sorted out by the tests that are running, but the CircleCI tests are the biggest batch.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Absolutely fantastic, and opens the door for more prompted choices. ddev config <provider> once had a version that did exactly like this, but there was no way to make it work on Windows and no way to test it.

Made a number of minor requests, the ones with suggestions you can batch and add.

One minor nit,

rfay_ddevprod___

cmd/ddev/cmd/restore_snapshot.go Outdated Show resolved Hide resolved
cmd/ddev/cmd/snapshot_restore.go Outdated Show resolved Hide resolved

if len(snapshots) == 0 {
util.Failed("No snapshots found for project %s", app.GetName())
os.Exit(1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
os.Exit(1)

cmd/ddev/cmd/snapshot_restore.go Outdated Show resolved Hide resolved
cmd/ddev/cmd/snapshot_restore_test.go Outdated Show resolved Hide resolved
docs/users/cli-usage.md Show resolved Hide resolved
cmd/ddev/cmd/snapshot_test.go Show resolved Hide resolved
@rfay
Copy link
Member

rfay commented Jan 4, 2021

I'm sure you saw the email from CircleCI - they suggest you might have clicked "follow" on the CircleCI page and so now you have to unfollow. Weirder than weird.

The situation you reported is most likely due to the fact that the user who created the pull-requests is also following the project fork on their personal CircleCI account (https://support.circleci.com/hc/en-us/articles/360008097173-Why-aren-t-pull-requests-triggering-jobs-on-my-organization-)

I would have thought only building on your fork would cause this.

@cmuench
Copy link
Collaborator Author

cmuench commented Jan 5, 2021

I'm sure you saw the email from CircleCI - they suggest you might have clicked "follow" on the CircleCI page and so now you have to unfollow. Weirder than weird.

The situation you reported is most likely due to the fact that the user who created the pull-requests is also following the project fork on their personal CircleCI account (https://support.circleci.com/hc/en-us/articles/360008097173-Why-aren-t-pull-requests-triggering-jobs-on-my-organization-)

I would have thought only building on your fork would cause this.

I am not following the project. Did not know that there is a circle-ci integration, before you mention it.
BTW I get this message if I went to the circle-ci page:

"There are no streaming updates available on this page because you do not follow this project."

@rfay
Copy link
Member

rfay commented Jan 5, 2021

Thanks for responding to the CircleCI folks. And I see it's being triggered now. No idea what was going on, but thanks for all!

@rfay rfay changed the title Add --latest flag to restore-snapshot command Add --latest flag to restore-snapshot command, fixes #1886 Jan 5, 2021
@rfay rfay linked an issue Jan 5, 2021 that may be closed by this pull request
@rfay rfay changed the title Add --latest flag to restore-snapshot command, fixes #1886 Add --latest flag to restore-snapshot command, fixes #1886, fixes #1163 Jan 5, 2021
@cmuench cmuench requested a review from rfay January 7, 2021 21:25
@rfay rfay force-pushed the feature/snapshot-restore-latest branch from 40e77d9 to 5acf08f Compare January 9, 2021 04:31
@rfay
Copy link
Member

rfay commented Jan 9, 2021

Rebased.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Looks great, fantastic!

@rfay rfay merged commit 51ede53 into ddev:master Jan 10, 2021
@rfay
Copy link
Member

rfay commented Jan 10, 2021

@cmuench if you're not exhausted with snapshots there are two remaining open issues regarding snapshots, and your brain is in there. They seem far simpler than the things you've already undertaken. But I know you don't have unlimited time, and also may be done with snapshots :) (Edit: I did the don't-reuse-existing-name one in #2739)

@rfay
Copy link
Member

rfay commented Jan 10, 2021

(Edit: I did the don't-reuse-existing-name one in #2739)

@cmuench cmuench deleted the feature/snapshot-restore-latest branch January 10, 2021 17:45
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.

Improve ddev snapshot UI - Suggest or require snapshot name, etc.
2 participants