From 218d91d76d49c7329704a80411ad2c115b074f84 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Mon, 1 Nov 2021 16:10:10 +0100 Subject: 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 --- pkg/domain/infra/abi/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/domain') diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index 8878bf128..7aa202334 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -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 -- cgit v1.2.3-54-g00ecf From 62ee24bb7c94556c8ed63553d2695d3c2ac24418 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Mon, 1 Nov 2021 20:15:00 +0100 Subject: More conforming libpod API and swagger types Signed-off-by: Matej Vasek --- pkg/api/handlers/types.go | 6 +++--- pkg/domain/entities/reports/prune.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'pkg/domain') diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index b90154e30..9ad3bcca0 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -42,9 +42,9 @@ type ContainersPruneReport struct { } type LibpodContainersPruneReport struct { - ID string `json:"id"` - SpaceReclaimed int64 `json:"space"` - PruneError string `json:"error"` + ID string `json:"Id"` + SpaceReclaimed int64 `json:"Space"` + PruneError string `json:"Err,omitempty"` } type Info struct { diff --git a/pkg/domain/entities/reports/prune.go b/pkg/domain/entities/reports/prune.go index 5494ac3ae..219e35b67 100644 --- a/pkg/domain/entities/reports/prune.go +++ b/pkg/domain/entities/reports/prune.go @@ -1,9 +1,9 @@ package reports type PruneReport struct { - Id string //nolint - Err error - Size uint64 + Id string `json:"Id"` //nolint + Err error `json:"Err,omitempty"` + Size uint64 `json:"Size"` } func PruneReportsIds(r []*PruneReport) []string { -- cgit v1.2.3-54-g00ecf