summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-01 16:10:10 +0200
committerGitHub <noreply@github.com>2020-04-01 16:10:10 +0200
commit82cbebcbea7f92be7e82bc11fdf1b30d7e194cdc (patch)
treeb819be57459895e73ebcd0ae8a1b204df7ba4849 /pkg/api/handlers/libpod
parent394f1c26d61cc8570b49444e1f431978bf101daa (diff)
parent26644d7cb85d5935bb59c7891ac9a81d6092673c (diff)
downloadpodman-82cbebcbea7f92be7e82bc11fdf1b30d7e194cdc.tar.gz
podman-82cbebcbea7f92be7e82bc11fdf1b30d7e194cdc.tar.bz2
podman-82cbebcbea7f92be7e82bc11fdf1b30d7e194cdc.zip
Merge pull request #5656 from baude/v2imagetag
podman v2 image tag and untag
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r--pkg/api/handlers/libpod/images.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go
index bb54450da..bc227d9a1 100644
--- a/pkg/api/handlers/libpod/images.go
+++ b/pkg/api/handlers/libpod/images.go
@@ -510,3 +510,29 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
}
utils.WriteResponse(w, http.StatusOK, handlers.IDResponse{ID: commitImage.ID()}) // nolint
}
+
+func UntagImage(w http.ResponseWriter, r *http.Request) {
+ runtime := r.Context().Value("runtime").(*libpod.Runtime)
+
+ 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
+ }
+ tag := "latest"
+ if len(r.Form.Get("tag")) > 0 {
+ tag = r.Form.Get("tag")
+ }
+ if len(r.Form.Get("repo")) < 1 {
+ utils.Error(w, "repo tag is required", http.StatusBadRequest, errors.New("repo parameter is required to tag an image"))
+ return
+ }
+ repo := r.Form.Get("repo")
+ tagName := fmt.Sprintf("%s:%s", repo, tag)
+ if err := newImage.UntagImage(tagName); err != nil {
+ utils.Error(w, "failed to untag", http.StatusInternalServerError, err)
+ return
+ }
+ utils.WriteResponse(w, http.StatusCreated, "")
+}