summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/images_remove.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-03-28 17:07:45 +0000
committerGitHub <noreply@github.com>2021-03-28 17:07:45 +0000
commitccbe7e94563e955d9f9b95cb3e3e15dcd45f8f22 (patch)
tree479007b11963eb3049e8ec12d17ae944af53dc18 /pkg/api/handlers/compat/images_remove.go
parent7e4b13b94699ee688c146afab727d2dec991376a (diff)
parenteb82c48cc5437811074703ee9fb16eda9e504469 (diff)
downloadpodman-ccbe7e94563e955d9f9b95cb3e3e15dcd45f8f22.tar.gz
podman-ccbe7e94563e955d9f9b95cb3e3e15dcd45f8f22.tar.bz2
podman-ccbe7e94563e955d9f9b95cb3e3e15dcd45f8f22.zip
Merge pull request #9829 from rhatdan/rmi
[NO TESTS NEEDED] Use same function podman-remote rmi as podman
Diffstat (limited to 'pkg/api/handlers/compat/images_remove.go')
-rw-r--r--pkg/api/handlers/compat/images_remove.go35
1 files changed, 21 insertions, 14 deletions
diff --git a/pkg/api/handlers/compat/images_remove.go b/pkg/api/handlers/compat/images_remove.go
index 874c57f16..e89558a86 100644
--- a/pkg/api/handlers/compat/images_remove.go
+++ b/pkg/api/handlers/compat/images_remove.go
@@ -4,7 +4,10 @@ import (
"net/http"
"github.com/containers/podman/v3/libpod"
+ "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
+ "github.com/containers/podman/v3/pkg/domain/entities"
+ "github.com/containers/podman/v3/pkg/domain/infra/abi"
"github.com/gorilla/schema"
"github.com/pkg/errors"
)
@@ -30,28 +33,32 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) {
}
}
name := utils.GetName(r)
- newImage, err := runtime.ImageRuntime().NewFromLocal(name)
- if err != nil {
- utils.ImageNotFound(w, name, errors.Wrapf(err, "failed to find image %s", name))
- return
+ imageEngine := abi.ImageEngine{Libpod: runtime}
+
+ options := entities.ImageRemoveOptions{
+ Force: query.Force,
}
+ report, rmerrors := imageEngine.Remove(r.Context(), []string{name}, options)
+ if len(rmerrors) > 0 && rmerrors[0] != nil {
+ err := rmerrors[0]
+ if errors.Cause(err) == define.ErrNoSuchImage {
+ utils.ImageNotFound(w, name, errors.Wrapf(err, "failed to find image %s", name))
+ return
+ }
- results, err := runtime.RemoveImage(r.Context(), newImage, query.Force)
- if err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
return
}
-
- response := make([]map[string]string, 0, len(results.Untagged)+1)
- deleted := make(map[string]string, 1)
- deleted["Deleted"] = results.Deleted
- response = append(response, deleted)
-
- for _, u := range results.Untagged {
+ response := make([]map[string]string, 0, len(report.Untagged)+1)
+ for _, d := range report.Deleted {
+ deleted := make(map[string]string, 1)
+ deleted["Deleted"] = d
+ response = append(response, deleted)
+ }
+ for _, u := range report.Untagged {
untagged := make(map[string]string, 1)
untagged["Untagged"] = u
response = append(response, untagged)
}
-
utils.WriteResponse(w, http.StatusOK, response)
}