diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-12-04 14:06:52 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-12-09 06:17:28 -0500 |
commit | a59e2a1a114c039e1780aa2b08b9452dc569cdf4 (patch) | |
tree | 1e40d530bd96ef9e4609383788175852465c49b8 /cmd/podman | |
parent | dd295f297b6dd51d22c64c75f4ef4f80f953bbde (diff) | |
download | podman-a59e2a1a114c039e1780aa2b08b9452dc569cdf4.tar.gz podman-a59e2a1a114c039e1780aa2b08b9452dc569cdf4.tar.bz2 podman-a59e2a1a114c039e1780aa2b08b9452dc569cdf4.zip |
Repeat system pruning until there is nothing removed
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/containers/prune.go | 2 | ||||
-rw-r--r-- | cmd/podman/images/prune.go | 2 | ||||
-rw-r--r-- | cmd/podman/pods/prune.go | 2 | ||||
-rw-r--r-- | cmd/podman/system/prune.go | 19 | ||||
-rw-r--r-- | cmd/podman/utils/utils.go | 20 | ||||
-rw-r--r-- | cmd/podman/volumes/prune.go | 2 |
6 files changed, 29 insertions, 18 deletions
diff --git a/cmd/podman/containers/prune.go b/cmd/podman/containers/prune.go index 9ac529b1c..d3842778b 100644 --- a/cmd/podman/containers/prune.go +++ b/cmd/podman/containers/prune.go @@ -78,5 +78,5 @@ func prune(cmd *cobra.Command, args []string) error { if err != nil { return err } - return utils.PrintContainerPruneResults(responses) + return utils.PrintContainerPruneResults(responses, false) } diff --git a/cmd/podman/images/prune.go b/cmd/podman/images/prune.go index e68fe5f40..268a68681 100644 --- a/cmd/podman/images/prune.go +++ b/cmd/podman/images/prune.go @@ -71,5 +71,5 @@ Are you sure you want to continue? [y/N] `) return err } - return utils.PrintImagePruneResults(results) + return utils.PrintImagePruneResults(results, false) } diff --git a/cmd/podman/pods/prune.go b/cmd/podman/pods/prune.go index 444b0f5e0..e069c9b7f 100644 --- a/cmd/podman/pods/prune.go +++ b/cmd/podman/pods/prune.go @@ -60,5 +60,5 @@ func prune(cmd *cobra.Command, args []string) error { if err != nil { return err } - return utils.PrintPodPruneResults(responses) + return utils.PrintPodPruneResults(responses, false) } diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index f2b9a3db5..f57689584 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -73,32 +73,31 @@ Are you sure you want to continue? [y/N] `, volumeString) return nil } } + // TODO: support for filters in system prune response, err := registry.ContainerEngine().SystemPrune(context.Background(), pruneOptions) if err != nil { return err } - // Print pod prune results - fmt.Println("Deleted Pods") - err = utils.PrintPodPruneResults(response.PodPruneReport) + // Print container prune results + err = utils.PrintContainerPruneResults(response.ContainerPruneReport, true) if err != nil { return err } - // Print container prune results - fmt.Println("Deleted Containers") - err = utils.PrintContainerPruneResults(response.ContainerPruneReport) + // Print pod prune results + err = utils.PrintPodPruneResults(response.PodPruneReport, true) if err != nil { return err } // Print Volume prune results if pruneOptions.Volume { - fmt.Println("Deleted Volumes") - err = utils.PrintVolumePruneResults(response.VolumePruneReport) + err = utils.PrintVolumePruneResults(response.VolumePruneReport, true) if err != nil { return err } } // Print Images prune results - fmt.Println("Deleted Images") - return utils.PrintImagePruneResults(response.ImagePruneReport) + utils.PrintImagePruneResults(response.ImagePruneReport, true) + + return nil } diff --git a/cmd/podman/utils/utils.go b/cmd/podman/utils/utils.go index 1c9e4d786..2ca2c4c92 100644 --- a/cmd/podman/utils/utils.go +++ b/cmd/podman/utils/utils.go @@ -26,8 +26,11 @@ func FileExists(path string) bool { return !file.IsDir() } -func PrintPodPruneResults(podPruneReports []*entities.PodPruneReport) error { +func PrintPodPruneResults(podPruneReports []*entities.PodPruneReport, heading bool) error { var errs OutputErrors + if heading && len(podPruneReports) > 0 { + fmt.Println("Deleted Pods") + } for _, r := range podPruneReports { if r.Err == nil { fmt.Println(r.Id) @@ -38,8 +41,11 @@ func PrintPodPruneResults(podPruneReports []*entities.PodPruneReport) error { return errs.PrintErrors() } -func PrintContainerPruneResults(containerPruneReport *entities.ContainerPruneReport) error { +func PrintContainerPruneResults(containerPruneReport *entities.ContainerPruneReport, heading bool) error { var errs OutputErrors + if heading && (len(containerPruneReport.ID) > 0 || len(containerPruneReport.Err) > 0) { + fmt.Println("Deleted Containers") + } for k := range containerPruneReport.ID { fmt.Println(k) } @@ -49,8 +55,11 @@ func PrintContainerPruneResults(containerPruneReport *entities.ContainerPruneRep return errs.PrintErrors() } -func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport) error { +func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport, heading bool) error { var errs OutputErrors + if heading && len(volumePruneReport) > 0 { + fmt.Println("Deleted Volumes") + } for _, r := range volumePruneReport { if r.Err == nil { fmt.Println(r.Id) @@ -61,7 +70,10 @@ func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport) er return errs.PrintErrors() } -func PrintImagePruneResults(imagePruneReport *entities.ImagePruneReport) error { +func PrintImagePruneResults(imagePruneReport *entities.ImagePruneReport, heading bool) error { + if heading && (len(imagePruneReport.Report.Id) > 0 || len(imagePruneReport.Report.Err) > 0) { + fmt.Println("Deleted Images") + } for _, i := range imagePruneReport.Report.Id { fmt.Println(i) } diff --git a/cmd/podman/volumes/prune.go b/cmd/podman/volumes/prune.go index 4c2136dcf..d1370120b 100644 --- a/cmd/podman/volumes/prune.go +++ b/cmd/podman/volumes/prune.go @@ -62,5 +62,5 @@ func prune(cmd *cobra.Command, args []string) error { if err != nil { return err } - return utils.PrintVolumePruneResults(responses) + return utils.PrintVolumePruneResults(responses, false) } |