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

Fixed prune with a confirmation, a force, and removed the spinner #145

Merged
merged 4 commits into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM golang:1.9-alpine
FROM golang:1.10-alpine

RUN apk add --no-cache \
ca-certificates \
curl \
git \
gcc \
libffi-dev \
Expand All @@ -12,8 +13,8 @@ RUN apk add --no-cache \
ruby-dev \
tar

RUN go get -u github.com/golang/dep/... \
&& go get -u github.com/alecthomas/gometalinter \
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
RUN go get -u github.com/alecthomas/gometalinter \
&& go get -u github.com/goreleaser/goreleaser

RUN gometalinter --install --update
Expand Down
16 changes: 8 additions & 8 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions commands/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ 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?") {
cmd.out.Info("Cleaning up unused Docker resources. This may take a while...")
/* #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.Warn("Cleanup aborted.")
}
cmd.out.Info("Unused Docker images, containers, volumes, and networks cleaned up.")

return cmd.Success("")
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
# Lint the codebase
lint:
extends: base
entrypoint: [ "gometalinter", "--vendor", "--config=gometalinter.json"]
entrypoint: [ "gometalinter", "--vendor", "--config=gometalinter.json", "--deadline=60s"]
command: "./..."

# Build rig, dropping off a working binary in build/darwin/rig.
Expand Down