summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-10 08:52:36 -0500
committerGitHub <noreply@github.com>2021-02-10 08:52:36 -0500
commitb4ca924365869d73aecd10bb99656b99ab8bf0ae (patch)
tree669426a9466d274cc4618484f9014902656357a1 /pkg
parent629a9796e5be3f239928600613170e430c3e17b7 (diff)
parentf4ece018b468e97e693d94628d3aa82acbcb6dc4 (diff)
downloadpodman-b4ca924365869d73aecd10bb99656b99ab8bf0ae.tar.gz
podman-b4ca924365869d73aecd10bb99656b99ab8bf0ae.tar.bz2
podman-b4ca924365869d73aecd10bb99656b99ab8bf0ae.zip
Merge pull request #9297 from matejvasek/apiv2_push_get_digest
Docker [APIv2] push sends digest in response body
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/images_push.go41
1 files changed, 34 insertions, 7 deletions
diff --git a/pkg/api/handlers/compat/images_push.go b/pkg/api/handlers/compat/images_push.go
index 34b53f34e..77d891546 100644
--- a/pkg/api/handlers/compat/images_push.go
+++ b/pkg/api/handlers/compat/images_push.go
@@ -1,6 +1,8 @@
package compat
import (
+ "fmt"
+ "io/ioutil"
"net/http"
"strings"
@@ -19,6 +21,14 @@ import (
func PushImage(w http.ResponseWriter, r *http.Request) {
decoder := r.Context().Value("decoder").(*schema.Decoder)
runtime := r.Context().Value("runtime").(*libpod.Runtime)
+
+ digestFile, err := ioutil.TempFile("", "digest.txt")
+ if err != nil {
+ utils.Error(w, "unable to create digest tempfile", http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
+ return
+ }
+ defer digestFile.Close()
+
// Now use the ABI implementation to prevent us from having duplicate
// code.
imageEngine := abi.ImageEngine{Libpod: runtime}
@@ -65,12 +75,13 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
password = authconf.Password
}
options := entities.ImagePushOptions{
- All: query.All,
- Authfile: authfile,
- Compress: query.Compress,
- Format: query.Format,
- Password: password,
- Username: username,
+ All: query.All,
+ Authfile: authfile,
+ Compress: query.Compress,
+ Format: query.Format,
+ Password: password,
+ Username: username,
+ DigestFile: digestFile.Name(),
}
if _, found := r.URL.Query()["tlsVerify"]; found {
options.SkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)
@@ -93,5 +104,21 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
return
}
- utils.WriteResponse(w, http.StatusOK, "")
+ digestBytes, err := ioutil.ReadAll(digestFile)
+ if err != nil {
+ utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to read digest tmp file"))
+ return
+ }
+
+ tag := query.Tag
+ if tag == "" {
+ tag = "latest"
+ }
+ respData := struct {
+ Status string `json:"status"`
+ }{
+ Status: fmt.Sprintf("%s: digest: %s size: null", tag, string(digestBytes)),
+ }
+
+ utils.WriteJSON(w, http.StatusOK, &respData)
}