Fix libpod API conformance to swagger

* Return empty array when nothing has been pruned.
* Use correct return type swagger doc-comment.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
Matej Vasek
2021-11-01 16:10:10 +01:00
parent 85bad0cc7c
commit 218d91d76d
3 changed files with 5 additions and 2 deletions

View File

@ -1069,7 +1069,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// - application/json
// responses:
// 200:
// $ref: "#/responses/DocsImageDeleteResponse"
// $ref: "#/responses/DocsLibpodPruneResponse"
// 500:
// $ref: '#/responses/InternalError'
r.Handle(VersionedPath("/libpod/images/prune"), s.APIHandler(libpod.PruneImages)).Methods(http.MethodPost)

View File

@ -57,7 +57,7 @@ func (ir *ImageEngine) Prune(ctx context.Context, opts entities.ImagePruneOption
pruneOptions.Filters = append(pruneOptions.Filters, "containers=false")
}
var pruneReports []*reports.PruneReport
pruneReports := make([]*reports.PruneReport, 0)
// Now prune all images until we converge.
numPreviouslyRemovedImages := 1

View File

@ -218,6 +218,9 @@ if ! grep -q '400 Bad Request' "${TMPD}/headers.txt"; then
BUILD_TEST_ERROR="1"
fi
t POST libpod/images/prune 200
t POST libpod/images/prune 200 length=0 []
cleanBuildTest
if [[ "${BUILD_TEST_ERROR}" ]]; then
exit 1