Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman-remote untag image is broken #7716

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions pkg/api/handlers/libpod/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,22 @@ func UntagImage(w http.ResponseWriter, r *http.Request) {
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
tags := []string{}
if len(r.Form.Get("repo")) > 0 {
repo := r.Form.Get("repo")
tag := "latest"
if len(r.Form.Get("tag")) > 0 {
tag = r.Form.Get("tag")
}
tags = []string{fmt.Sprintf("%s:%s", repo, tag)}
} else {
tags = newImage.Names()
}
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
for _, tag := range tags {
if err := newImage.UntagImage(tag); err != nil {
utils.Error(w, "failed to untag", http.StatusInternalServerError, err)
return
}
}
utils.WriteResponse(w, http.StatusCreated, "")
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/bindings/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,12 @@ func Untag(ctx context.Context, nameOrID, tag, repo string) error {
return err
}
params := url.Values{}
params.Set("tag", tag)
params.Set("repo", repo)
if len(tag) > 0 {
params.Set("tag", tag)
}
if len(repo) > 0 {
params.Set("repo", repo)
}
response, err := conn.DoRequest(nil, http.MethodPost, "/images/%s/untag", params, nil, nameOrID)
if err != nil {
return err
Expand Down
9 changes: 1 addition & 8 deletions pkg/domain/infra/tunnel/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/podman/v2/pkg/bindings"
images "github.com/containers/podman/v2/pkg/bindings/images"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/domain/utils"
Expand Down Expand Up @@ -139,15 +138,9 @@ func (ir *ImageEngine) Tag(ctx context.Context, nameOrID string, tags []string,
}

func (ir *ImageEngine) Untag(ctx context.Context, nameOrID string, tags []string, options entities.ImageUntagOptions) error {
// Remove all tags if none are provided
if len(tags) == 0 {
newImage, err := images.GetImage(ir.ClientCxt, nameOrID, bindings.PFalse)
if err != nil {
return err
}
tags = newImage.NamesHistory
return images.Untag(ir.ClientCxt, nameOrID, "", "")
}

for _, newTag := range tags {
var (
tag, repo string
Expand Down
1 change: 0 additions & 1 deletion test/e2e/untag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ var _ = Describe("Podman untag", func() {
})

It("podman untag all", func() {
SkipIfRemote("FIXME This should work on podman-remote")
setup := podmanTest.PodmanNoCache([]string{"pull", ALPINE})
setup.WaitWithDefaultTimeout()
Expect(setup.ExitCode()).To(Equal(0))
Expand Down