diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-12-23 18:01:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-23 18:01:32 +0100 |
commit | d62fce0c873bdd1341af15eba4418ff83af7edba (patch) | |
tree | 9c4f9b09f18ffb47ecc50b6b5058e64c390ec57d /pkg | |
parent | d43bff7cc6484927487ded4246e7625c8b42b5e8 (diff) | |
parent | 4f09cfdaccfdd0f1deb01e52c7e1b18a9cec7d49 (diff) | |
download | podman-d62fce0c873bdd1341af15eba4418ff83af7edba.tar.gz podman-d62fce0c873bdd1341af15eba4418ff83af7edba.tar.bz2 podman-d62fce0c873bdd1341af15eba4418ff83af7edba.zip |
Merge pull request #4743 from baude/imageresponse
add struct response for removal of images
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/adapter/runtime.go | 2 | ||||
-rw-r--r-- | pkg/adapter/runtime_remote.go | 11 | ||||
-rw-r--r-- | pkg/varlinkapi/images.go | 18 |
3 files changed, 28 insertions, 3 deletions
diff --git a/pkg/adapter/runtime.go b/pkg/adapter/runtime.go index ac843b655..dd4f0f35f 100644 --- a/pkg/adapter/runtime.go +++ b/pkg/adapter/runtime.go @@ -155,7 +155,7 @@ func (r *LocalRuntime) New(ctx context.Context, name, signaturePolicyPath, authf } // RemoveImage calls into local storage and removes an image -func (r *LocalRuntime) RemoveImage(ctx context.Context, img *ContainerImage, force bool) (string, error) { +func (r *LocalRuntime) RemoveImage(ctx context.Context, img *ContainerImage, force bool) (*image.ImageDeleteResponse, error) { return r.Runtime.RemoveImage(ctx, img.Image, force) } diff --git a/pkg/adapter/runtime_remote.go b/pkg/adapter/runtime_remote.go index 87b4999ce..fe5cc4fef 100644 --- a/pkg/adapter/runtime_remote.go +++ b/pkg/adapter/runtime_remote.go @@ -414,8 +414,15 @@ func (ci *ContainerImage) TagImage(tag string) error { } // RemoveImage calls varlink to remove an image -func (r *LocalRuntime) RemoveImage(ctx context.Context, img *ContainerImage, force bool) (string, error) { - return iopodman.RemoveImage().Call(r.Conn, img.InputName, force) +func (r *LocalRuntime) RemoveImage(ctx context.Context, img *ContainerImage, force bool) (*image.ImageDeleteResponse, error) { + ir := image.ImageDeleteResponse{} + response, err := iopodman.RemoveImageWithResponse().Call(r.Conn, img.InputName, force) + if err != nil { + return nil, err + } + ir.Deleted = response.Deleted + ir.Untagged = append(ir.Untagged, response.Untagged...) + return &ir, nil } // History returns the history of an image and its layers 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 { |