summaryrefslogtreecommitdiff
path: root/cmd/podman/utils/utils.go
diff options
context:
space:
mode:
authorBaron Lenardson <lenardson.baron@gmail.com>2020-12-22 20:02:08 -0600
committerBaron Lenardson <lenardson.baron@gmail.com>2020-12-30 19:57:35 -0600
commitb90f7f90952f16e0c1b05e8f750b56bb43711b5e (patch)
treeba33228b57820f0f59b9b9563b2e79ce407dd2ed /cmd/podman/utils/utils.go
parentc6c9b45985790af50a78da4c222e10672f92c629 (diff)
downloadpodman-b90f7f90952f16e0c1b05e8f750b56bb43711b5e.tar.gz
podman-b90f7f90952f16e0c1b05e8f750b56bb43711b5e.tar.bz2
podman-b90f7f90952f16e0c1b05e8f750b56bb43711b5e.zip
Rework pruning to report reclaimed space
This change adds code to report the reclaimed space after a prune. Reclaimed space from volumes, images, and containers is recorded during the prune call in a PruneReport struct. These structs are collected into a slice during a system prune and processed afterwards to calculate the total reclaimed space. Closes #8658 Signed-off-by: Baron Lenardson <lenardson.baron@gmail.com>
Diffstat (limited to 'cmd/podman/utils/utils.go')
-rw-r--r--cmd/podman/utils/utils.go35
1 files changed, 17 insertions, 18 deletions
diff --git a/cmd/podman/utils/utils.go b/cmd/podman/utils/utils.go
index 2ca2c4c92..f42243f69 100644
--- a/cmd/podman/utils/utils.go
+++ b/cmd/podman/utils/utils.go
@@ -5,6 +5,7 @@ import (
"os"
"github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/domain/entities/reports"
)
// IsDir returns true if the specified path refers to a directory.
@@ -41,21 +42,21 @@ func PrintPodPruneResults(podPruneReports []*entities.PodPruneReport, heading bo
return errs.PrintErrors()
}
-func PrintContainerPruneResults(containerPruneReport *entities.ContainerPruneReport, heading bool) error {
+func PrintContainerPruneResults(containerPruneReports []*reports.PruneReport, heading bool) error {
var errs OutputErrors
- if heading && (len(containerPruneReport.ID) > 0 || len(containerPruneReport.Err) > 0) {
+ if heading && (len(containerPruneReports) > 0) {
fmt.Println("Deleted Containers")
}
- for k := range containerPruneReport.ID {
- fmt.Println(k)
- }
- for _, v := range containerPruneReport.Err {
- errs = append(errs, v)
+ for _, v := range containerPruneReports {
+ fmt.Println(v.Id)
+ if v.Err != nil {
+ errs = append(errs, v.Err)
+ }
}
return errs.PrintErrors()
}
-func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport, heading bool) error {
+func PrintVolumePruneResults(volumePruneReport []*reports.PruneReport, heading bool) error {
var errs OutputErrors
if heading && len(volumePruneReport) > 0 {
fmt.Println("Deleted Volumes")
@@ -70,18 +71,16 @@ func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport, he
return errs.PrintErrors()
}
-func PrintImagePruneResults(imagePruneReport *entities.ImagePruneReport, heading bool) error {
- if heading && (len(imagePruneReport.Report.Id) > 0 || len(imagePruneReport.Report.Err) > 0) {
+func PrintImagePruneResults(imagePruneReports []*reports.PruneReport, heading bool) error {
+ if heading {
fmt.Println("Deleted Images")
}
- for _, i := range imagePruneReport.Report.Id {
- fmt.Println(i)
- }
- for _, e := range imagePruneReport.Report.Err {
- fmt.Fprint(os.Stderr, e.Error()+"\n")
- }
- if imagePruneReport.Size > 0 {
- fmt.Fprintf(os.Stdout, "Size: %d\n", imagePruneReport.Size)
+ for _, r := range imagePruneReports {
+ fmt.Println(r.Id)
+ if r.Err != nil {
+ fmt.Fprint(os.Stderr, r.Err.Error()+"\n")
+ }
}
+
return nil
}