44 "context"
55 "errors"
66 "fmt"
7+ "strings"
78
89 "github.com/docker/cli/cli"
910 "github.com/docker/cli/cli/command"
@@ -61,7 +62,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
6162const warning = `WARNING! This will remove all stopped containers.
6263Are you sure you want to continue?`
6364
64- func runPrune (ctx context.Context , dockerCli command.Cli , options pruneOptions ) (spaceReclaimed uint64 , output string , err error ) {
65+ func runPrune (ctx context.Context , dockerCli command.Cli , options pruneOptions ) (spaceReclaimed uint64 , output string , _ error ) {
6566 pruneFilters := command .PruneFilters (dockerCli , options .filter .Value ())
6667
6768 if ! options .force {
@@ -81,15 +82,16 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
8182 return 0 , "" , err
8283 }
8384
85+ var out strings.Builder
8486 if len (res .Report .ContainersDeleted ) > 0 {
85- output = "Deleted Containers:\n "
87+ out . WriteString ( "Deleted Containers:\n " )
8688 for _ , id := range res .Report .ContainersDeleted {
87- output += id + "\n "
89+ out . WriteString ( id + "\n " )
8890 }
8991 spaceReclaimed = res .Report .SpaceReclaimed
9092 }
9193
92- return spaceReclaimed , output , nil
94+ return spaceReclaimed , out . String () , nil
9395}
9496
9597type cancelledErr struct { error }
0 commit comments