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 7, 2024
1 parent 8d5ec11 commit 533be65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/api/handlers/compat/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ 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 && len(tagOrDigest) > 0 && strings.Contains(name, separator) {
parts := strings.Split(name, separator)
return fmt.Sprintf("%s%s%s", strings.Join(parts[:len(parts)-1], ""), 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 533be65

Please sign in to comment.