-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fixed prune with a confirmation, a force, and removed the spinner #145
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c2a899f
Fixed prune with a confirmation, a force, and removed the spinner
febbraro 65709d3
added warning message and spinner
febbraro 257badc
removed spinner for better output flow
febbraro f082aec
Upgraded to golang 1.10, use dep official release, and added linter f…
febbraro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,11 +26,16 @@ func (cmd *Prune) Commands() []cli.Command { | |
|
||
// Run executes the `rig prune` command | ||
func (cmd *Prune) Run(c *cli.Context) error { | ||
cmd.out.Spin("Cleaning up unused Docker resources...") | ||
/* #nosec */ | ||
if exitCode := util.PassthruCommand(exec.Command("docker", "system", "prune", "--all", "--volumes")); exitCode != 0 { | ||
return cmd.Failure("Failure pruning Docker resources.", "COMMAND-ERROR", 13) | ||
|
||
if util.AskYesNo("Are you sure you want to remove all unused containers, networks, images, caches, and volumes?") { | ||
/* #nosec */ | ||
if exitCode := util.PassthruCommand(exec.Command("docker", "system", "prune", "--all", "--volumes", "--force")); exitCode != 0 { | ||
return cmd.Failure("Failure pruning Docker resources.", "COMMAND-ERROR", 13) | ||
} | ||
cmd.out.Info("Unused Docker images, containers, volumes, and networks cleaned up.") | ||
} else { | ||
cmd.out.Info("Cleanup aborted.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be cmd.out.Warn()? (This is particularly useful if we run a spinner to differentiate no-action from successful action.) |
||
} | ||
cmd.out.Info("Unused Docker images, containers, volumes, and networks cleaned up.") | ||
|
||
return cmd.Success("") | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we start a spinner inside here in case the command might take awhile to run?
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 kept the spinner I think it would still go above this conditional, just inside the AskYesNo block. I'm in favor of it since it can definitely take a while to run and there is no real indication that things are happening. If we leave it off then perhaps just mention in the prompt that this may take a while to execute.
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.
Well, the actual prune command has a lot of output as it is cleaning up things, so the spinner will likely get in the way. I'll test it out to see.
I'm thinking no spinner, but I'll see what it looks like.
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 just did a test and I didn't see any output (so if some is being generated then the spinner is gobbling it). Interestingly, I didn't see the success message until I hit "Enter" while the spinner was running so I thought things might have actually gotten stuck. Interested to see if you get the same experience (and if so then perhaps the note that it'll will take a bit is a better course).