pruneFn calls the Image Prune API for use in "docker system prune", and returns the amount of space reclaimed and a detailed output string.
(ctx context.Context, dockerCLI command.Cli, options pruner.PruneOptions)
| 120 | // pruneFn calls the Image Prune API for use in "docker system prune", |
| 121 | // and returns the amount of space reclaimed and a detailed output string. |
| 122 | func pruneFn(ctx context.Context, dockerCLI command.Cli, options pruner.PruneOptions) (uint64, string, error) { |
| 123 | if !options.Confirmed { |
| 124 | // Dry-run: perform validation and produce confirmation before pruning. |
| 125 | var confirmMsg string |
| 126 | if options.All { |
| 127 | confirmMsg = "all images without at least one container associated to them" |
| 128 | } else { |
| 129 | confirmMsg = "all dangling images" |
| 130 | } |
| 131 | return 0, confirmMsg, cancelledErr{errors.New("image prune has been cancelled")} |
| 132 | } |
| 133 | return runPrune(ctx, dockerCLI, pruneOptions{ |
| 134 | force: true, |
| 135 | all: options.All, |
| 136 | filter: options.Filter, |
| 137 | }) |
| 138 | } |