summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod
diff options
context:
space:
mode:
authorSujil02 <sushah@redhat.com>2020-04-02 22:56:59 -0400
committerSujil02 <sushah@redhat.com>2020-04-17 17:30:58 -0400
commit37f3b191d5318b7d25893eabf4e57b568c326773 (patch)
tree8c2792aa1e7b4846dffc5708cf13a0eb500f4a19 /pkg/api/handlers/libpod
parentaa97cb5f42a35de02d520f6c3006600505a3d6d9 (diff)
downloadpodman-37f3b191d5318b7d25893eabf4e57b568c326773.tar.gz
podman-37f3b191d5318b7d25893eabf4e57b568c326773.tar.bz2
podman-37f3b191d5318b7d25893eabf4e57b568c326773.zip
Add pod prune for api v2.
Add the ability to prune pods for api v2, Includes the addition of force flag, for client side prompt. Update test suite to support this use case. Signed-off-by: Sujil02 <sushah@redhat.com>
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r--pkg/api/handlers/libpod/pods.go11
-rw-r--r--pkg/api/handlers/libpod/swagger.go7
2 files changed, 16 insertions, 2 deletions
diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go
index 92556bb61..618d48ac0 100644
--- a/pkg/api/handlers/libpod/pods.go
+++ b/pkg/api/handlers/libpod/pods.go
@@ -232,13 +232,20 @@ func PodRestart(w http.ResponseWriter, r *http.Request) {
func PodPrune(w http.ResponseWriter, r *http.Request) {
var (
runtime = r.Context().Value("runtime").(*libpod.Runtime)
+ reports []*entities.PodPruneReport
)
- pruned, err := runtime.PrunePods()
+ responses, err := runtime.PrunePods(r.Context())
if err != nil {
utils.InternalServerError(w, err)
return
}
- utils.WriteResponse(w, http.StatusOK, pruned)
+ for k, v := range responses {
+ reports = append(reports, &entities.PodPruneReport{
+ Err: v,
+ Id: k,
+ })
+ }
+ utils.WriteResponse(w, http.StatusOK, reports)
}
func PodPause(w http.ResponseWriter, r *http.Request) {
diff --git a/pkg/api/handlers/libpod/swagger.go b/pkg/api/handlers/libpod/swagger.go
index ed19462c6..46426eb6b 100644
--- a/pkg/api/handlers/libpod/swagger.go
+++ b/pkg/api/handlers/libpod/swagger.go
@@ -70,6 +70,13 @@ type swagStartPodResponse struct {
Body entities.PodStartReport
}
+// Prune pod
+// swagger:response PodPruneReport
+type swagPrunePodResponse struct {
+ // in:body
+ Body entities.PodPruneReport
+}
+
// Rm pod
// swagger:response PodRmReport
type swagRmPodResponse struct {