aboutsummaryrefslogtreecommitdiff
path: root/pkg/varlinkapi
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-12-23 09:33:29 -0600
committerbaude <bbaude@redhat.com>2019-12-23 10:02:14 -0600
commit4f09cfdaccfdd0f1deb01e52c7e1b18a9cec7d49 (patch)
tree491fcc6d89f0cabb26fdf2578e830b332205d589 /pkg/varlinkapi
parentfcd48db4d24f6dba4fb2652d72aa0d86e167aa0c (diff)
downloadpodman-4f09cfdaccfdd0f1deb01e52c7e1b18a9cec7d49.tar.gz
podman-4f09cfdaccfdd0f1deb01e52c7e1b18a9cec7d49.tar.bz2
podman-4f09cfdaccfdd0f1deb01e52c7e1b18a9cec7d49.zip
add struct response for removal of images
when removing an image from storage, we should return a struct that details what was untagged vs deleted. this replaces the simple println's used previously and assists in API development. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/varlinkapi')
-rw-r--r--pkg/varlinkapi/images.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go
index 1d46c5b71..ac92343d0 100644
--- a/pkg/varlinkapi/images.go
+++ b/pkg/varlinkapi/images.go
@@ -465,6 +465,24 @@ func (i *LibpodAPI) RemoveImage(call iopodman.VarlinkCall, name string, force bo
return call.ReplyRemoveImage(newImage.ID())
}
+// RemoveImageWithResponse accepts an image name and force bool. It returns details about what
+// was done in removeimageresponse struct.
+func (i *LibpodAPI) RemoveImageWithResponse(call iopodman.VarlinkCall, name string, force bool) error {
+ ir := iopodman.RemoveImageResponse{}
+ ctx := getContext()
+ newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
+ if err != nil {
+ return call.ReplyImageNotFound(name, err.Error())
+ }
+ response, err := i.Runtime.RemoveImage(ctx, newImage, force)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ ir.Untagged = append(ir.Untagged, response.Untagged...)
+ ir.Deleted = response.Deleted
+ return call.ReplyRemoveImageWithResponse(ir)
+}
+
// SearchImages searches all registries configured in /etc/containers/registries.conf for an image
// Requires an image name and a search limit as int
func (i *LibpodAPI) SearchImages(call iopodman.VarlinkCall, query string, limit *int64, filter iopodman.ImageSearchFilter) error {