From ec4060aef6c77c049fc2c3b6438ebb5590f6ab69 Mon Sep 17 00:00:00 2001 From: Sujil02 Date: Wed, 8 Apr 2020 04:49:32 -0400 Subject: Ability to prune container in api V2 Adds ability to prune containers for v2. Adds client side prompt with force flag and filters options to prune. Signed-off-by: Sujil02 --- pkg/api/handlers/compat/containers_prune.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'pkg/api/handlers/compat/containers_prune.go') diff --git a/pkg/api/handlers/compat/containers_prune.go b/pkg/api/handlers/compat/containers_prune.go index a56c3903d..bf3aecd65 100644 --- a/pkg/api/handlers/compat/containers_prune.go +++ b/pkg/api/handlers/compat/containers_prune.go @@ -4,8 +4,8 @@ import ( "net/http" "github.com/containers/libpod/libpod" - "github.com/containers/libpod/pkg/api/handlers" "github.com/containers/libpod/pkg/api/handlers/utils" + "github.com/containers/libpod/pkg/domain/entities" "github.com/docker/docker/api/types" "github.com/gorilla/schema" "github.com/pkg/errors" @@ -40,14 +40,11 @@ func PruneContainers(w http.ResponseWriter, r *http.Request) { // Libpod response differs if utils.IsLibpodRequest(r) { - var response []handlers.LibpodContainersPruneReport - for ctrID, size := range prunedContainers { - response = append(response, handlers.LibpodContainersPruneReport{ID: ctrID, SpaceReclaimed: size}) + report := &entities.ContainerPruneReport{ + Err: pruneErrors, + ID: prunedContainers, } - for ctrID, err := range pruneErrors { - response = append(response, handlers.LibpodContainersPruneReport{ID: ctrID, PruneError: err.Error()}) - } - utils.WriteResponse(w, http.StatusOK, response) + utils.WriteResponse(w, http.StatusOK, report) return } for ctrID, size := range prunedContainers { -- cgit v1.2.3-54-g00ecf