aboutsummaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi
diff options
context:
space:
mode:
authorToshiki Sonoda <sonoda.toshiki@fujitsu.com>2022-07-08 08:33:20 +0900
committerToshiki Sonoda <sonoda.toshiki@fujitsu.com>2022-07-08 08:33:20 +0900
commitd1754bdd4f299c8d92671493add4a69ef7850e1d (patch)
treec4fd3d741d641d16267aa8431c430cc095ac250e /pkg/domain/infra/abi
parent700f1faf6e5449e13970fc17311b09e4ca9ac2c3 (diff)
downloadpodman-d1754bdd4f299c8d92671493add4a69ef7850e1d.tar.gz
podman-d1754bdd4f299c8d92671493add4a69ef7850e1d.tar.bz2
podman-d1754bdd4f299c8d92671493add4a69ef7850e1d.zip
Refactored networkPrune function
Refactored the networkPrune function to improve readability. This commit changes the `networkPrune` function to use the `PrintNetworkPruneResults` function. [NO NEW TESTS NEEDED] Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
Diffstat (limited to 'pkg/domain/infra/abi')
-rw-r--r--pkg/domain/infra/abi/system.go29
1 files changed, 13 insertions, 16 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 96690afef..0faae01c8 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -157,15 +157,15 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys
// TODO: Figure out cleaner way to handle all of the different PruneOptions
// Remove all unused pods.
- podPruneReport, err := ic.prunePodHelper(ctx)
+ podPruneReports, err := ic.prunePodHelper(ctx)
if err != nil {
return nil, err
}
- if len(podPruneReport) > 0 {
+ if len(podPruneReports) > 0 {
found = true
}
- systemPruneReport.PodPruneReport = append(systemPruneReport.PodPruneReport, podPruneReport...)
+ systemPruneReport.PodPruneReport = append(systemPruneReport.PodPruneReport, podPruneReports...)
// Remove all unused containers.
containerPruneOptions := entities.ContainerPruneOptions{}
@@ -201,38 +201,35 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys
networkPruneOptions := entities.NetworkPruneOptions{}
networkPruneOptions.Filters = options.Filters
- networkPruneReport, err := ic.NetworkPrune(ctx, networkPruneOptions)
+ networkPruneReports, err := ic.NetworkPrune(ctx, networkPruneOptions)
if err != nil {
return nil, err
}
- if len(networkPruneReport) > 0 {
+ if len(networkPruneReports) > 0 {
found = true
}
- for _, net := range networkPruneReport {
- systemPruneReport.NetworkPruneReports = append(systemPruneReport.NetworkPruneReports, &reports.PruneReport{
- Id: net.Name,
- Err: net.Error,
- Size: 0,
- })
- }
+
+ // Networks reclaimedSpace are always '0'.
+ systemPruneReport.NetworkPruneReports = append(systemPruneReport.NetworkPruneReports, networkPruneReports...)
// Remove unused volume data.
if options.Volume {
volumePruneOptions := entities.VolumePruneOptions{}
volumePruneOptions.Filters = (url.Values)(options.Filters)
- volumePruneReport, err := ic.VolumePrune(ctx, volumePruneOptions)
+ volumePruneReports, err := ic.VolumePrune(ctx, volumePruneOptions)
if err != nil {
return nil, err
}
- if len(volumePruneReport) > 0 {
+ if len(volumePruneReports) > 0 {
found = true
}
- reclaimedSpace += reports.PruneReportsSize(volumePruneReport)
- systemPruneReport.VolumePruneReports = append(systemPruneReport.VolumePruneReports, volumePruneReport...)
+ reclaimedSpace += reports.PruneReportsSize(volumePruneReports)
+ systemPruneReport.VolumePruneReports = append(systemPruneReport.VolumePruneReports, volumePruneReports...)
}
}
+
systemPruneReport.ReclaimedSpace = reclaimedSpace
return systemPruneReport, nil
}