From 3f4d91508e7d8709b8773b6ac8e7e80f0817254d Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 18 Jul 2017 09:49:02 +0200 Subject: [PATCH] =?UTF-8?q?Remove=20useless=20prune=20package=20?= =?UTF-8?q?=F0=9F=91=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `cli/command/prune` just does some aliasing of `Prune*` methods, doesn't have any use. Signed-off-by: Vincent Demeester --- cli/command/prune/prune.go | 30 ------------------------------ cli/command/system/prune.go | 33 ++++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 35 deletions(-) delete mode 100644 cli/command/prune/prune.go diff --git a/cli/command/prune/prune.go b/cli/command/prune/prune.go deleted file mode 100644 index 12429da907..0000000000 --- a/cli/command/prune/prune.go +++ /dev/null @@ -1,30 +0,0 @@ -package prune - -import ( - "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/container" - "github.com/docker/cli/cli/command/image" - "github.com/docker/cli/cli/command/network" - "github.com/docker/cli/cli/command/volume" - "github.com/docker/cli/opts" -) - -// RunContainerPrune executes a prune command for containers -func RunContainerPrune(dockerCli command.Cli, filter opts.FilterOpt) (uint64, string, error) { - return container.RunPrune(dockerCli, filter) -} - -// RunVolumePrune executes a prune command for volumes -func RunVolumePrune(dockerCli command.Cli, filter opts.FilterOpt) (uint64, string, error) { - return volume.RunPrune(dockerCli, filter) -} - -// RunImagePrune executes a prune command for images -func RunImagePrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { - return image.RunPrune(dockerCli, all, filter) -} - -// RunNetworkPrune executes a prune command for networks -func RunNetworkPrune(dockerCli command.Cli, filter opts.FilterOpt) (uint64, string, error) { - return network.RunPrune(dockerCli, filter) -} diff --git a/cli/command/system/prune.go b/cli/command/system/prune.go index e9383e43d3..d2305822f9 100644 --- a/cli/command/system/prune.go +++ b/cli/command/system/prune.go @@ -7,7 +7,10 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/prune" + "github.com/docker/cli/cli/command/container" + "github.com/docker/cli/cli/command/image" + "github.com/docker/cli/cli/command/network" + "github.com/docker/cli/cli/command/volume" "github.com/docker/cli/opts" units "github.com/docker/go-units" "github.com/spf13/cobra" @@ -52,6 +55,26 @@ const confirmationTemplate = `WARNING! This will remove: {{- end }} Are you sure you want to continue?` +// runContainerPrune executes a prune command for containers +func runContainerPrune(dockerCli command.Cli, filter opts.FilterOpt) (uint64, string, error) { + return container.RunPrune(dockerCli, filter) +} + +// runNetworkPrune executes a prune command for networks +func runNetworkPrune(dockerCli command.Cli, filter opts.FilterOpt) (uint64, string, error) { + return network.RunPrune(dockerCli, filter) +} + +// runVolumePrune executes a prune command for volumes +func runVolumePrune(dockerCli command.Cli, filter opts.FilterOpt) (uint64, string, error) { + return volume.RunPrune(dockerCli, filter) +} + +// runImagePrune executes a prune command for images +func runImagePrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { + return image.RunPrune(dockerCli, all, filter) +} + func runPrune(dockerCli command.Cli, options pruneOptions) error { if !options.force && !command.PromptForConfirmation(dockerCli.In(), dockerCli.Out(), confirmationMessage(options)) { return nil @@ -59,11 +82,11 @@ func runPrune(dockerCli command.Cli, options pruneOptions) error { var spaceReclaimed uint64 pruneFuncs := []func(dockerCli command.Cli, filter opts.FilterOpt) (uint64, string, error){ - prune.RunContainerPrune, - prune.RunNetworkPrune, + runContainerPrune, + runNetworkPrune, } if options.pruneVolumes { - pruneFuncs = append(pruneFuncs, prune.RunVolumePrune) + pruneFuncs = append(pruneFuncs, runVolumePrune) } for _, pruneFn := range pruneFuncs { @@ -77,7 +100,7 @@ func runPrune(dockerCli command.Cli, options pruneOptions) error { } } - spc, output, err := prune.RunImagePrune(dockerCli, options.all, options.filter) + spc, output, err := runImagePrune(dockerCli, options.all, options.filter) if err != nil { return err }