Skip to content

Commit

Permalink
images/create: handle tag/digest if Tag specified
Browse files Browse the repository at this point in the history
Podman handles /images/create better when fromImage and Tag are
specified. Now the tag/digest value provided in Tag will replace the one
in fromImage

Fixes: #23938

Signed-off-by: Nicola Sella <[email protected]>
  • Loading branch information
inknos committed Oct 9, 2024
1 parent 8d5ec11 commit 1778a90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/api/handlers/compat/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func mergeNameAndTagOrDigest(name, tagOrDigest string) string {
// We have a digest, so let's change the separator.
separator = "@"
}
// if both name and tagOrDigest are defined we try to use the tagOrDigest image part and override the tag/digest
if len(name) > 0 && strings.Contains(name, separator) {
index := strings.LastIndex(name, separator)
return fmt.Sprintf("%s%s%s", name[:index], separator, tagOrDigest)
}
return fmt.Sprintf("%s%s%s", name, separator, tagOrDigest)
}

Expand Down
3 changes: 3 additions & 0 deletions test/apiv2/10-images.at
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ fi
t POST "/images/create?fromImage=quay.io/idonotexist/idonotexist:dummy" $expect_code \
.message="$expect_msg"

# compat api pull image with fromImage and Tag
t GET "/images/create?fromImage=alpine:latest&tag=latest" 200 .error~null .status~".*Download complete.*"

# Export an image on the local
t GET libpod/images/nonesuch/get 404
t GET libpod/images/$iid/get?format=foo 500
Expand Down

0 comments on commit 1778a90

Please sign in to comment.