diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-07-11 12:53:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 12:53:59 +0000 |
commit | 0df8c6e1572c30fed45d96a4761060d3d440d69d (patch) | |
tree | 77539110d85fa8f4400eaa4609ddd7bbc4da6bf3 /cmd/podman | |
parent | 3691c9b1ba8e63f56b5cc36cdb1670fcfbdba0a1 (diff) | |
parent | d1754bdd4f299c8d92671493add4a69ef7850e1d (diff) | |
download | podman-0df8c6e1572c30fed45d96a4761060d3d440d69d.tar.gz podman-0df8c6e1572c30fed45d96a4761060d3d440d69d.tar.bz2 podman-0df8c6e1572c30fed45d96a4761060d3d440d69d.zip |
Merge pull request #14826 from sstosh/net-prune
Refactored networkPrune function
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/networks/prune.go | 15 | ||||
-rw-r--r-- | cmd/podman/utils/utils.go | 8 |
2 files changed, 6 insertions, 17 deletions
diff --git a/cmd/podman/networks/prune.go b/cmd/podman/networks/prune.go index fa621ebac..ee5389aa7 100644 --- a/cmd/podman/networks/prune.go +++ b/cmd/podman/networks/prune.go @@ -52,10 +52,7 @@ func init() { } func networkPrune(cmd *cobra.Command, _ []string) error { - var ( - errs utils.OutputErrors - err error - ) + var err error if !force { reader := bufio.NewReader(os.Stdin) fmt.Println("WARNING! This will remove all networks not used by at least one container.") @@ -77,13 +74,5 @@ func networkPrune(cmd *cobra.Command, _ []string) error { setExitCode(err) return err } - for _, r := range responses { - if r.Error == nil { - fmt.Println(r.Name) - } else { - setExitCode(r.Error) - errs = append(errs, r.Error) - } - } - return errs.PrintErrors() + return utils.PrintNetworkPruneResults(responses, false) } diff --git a/cmd/podman/utils/utils.go b/cmd/podman/utils/utils.go index 2ae123388..a265faf51 100644 --- a/cmd/podman/utils/utils.go +++ b/cmd/podman/utils/utils.go @@ -85,16 +85,16 @@ func PrintImagePruneResults(imagePruneReports []*reports.PruneReport, heading bo return nil } -func PrintNetworkPruneResults(networkPruneReport []*reports.PruneReport, heading bool) error { +func PrintNetworkPruneResults(networkPruneReport []*entities.NetworkPruneReport, heading bool) error { var errs OutputErrors if heading && len(networkPruneReport) > 0 { fmt.Println("Deleted Networks") } for _, r := range networkPruneReport { - if r.Err == nil { - fmt.Println(r.Id) + if r.Error == nil { + fmt.Println(r.Name) } else { - errs = append(errs, r.Err) + errs = append(errs, r.Error) } } return errs.PrintErrors() |