Skip to content

Commit b82e336

Browse files
Merge pull request #21004 from umohnani8/push-endpoint
Fix push endpoint stream
2 parents 5e76a88 + 126670d commit b82e336

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

pkg/api/handlers/libpod/images_push.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
8181
ForceCompressionFormat: query.ForceCompressionFormat,
8282
Format: query.Format,
8383
Password: password,
84-
Quiet: true,
84+
Quiet: query.Quiet,
8585
RemoveSignatures: query.RemoveSignatures,
8686
Username: username,
8787
}
@@ -150,9 +150,9 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
150150
}
151151
if pushError != nil {
152152
stream.Error = pushError.Error()
153-
if err := enc.Encode(stream); err != nil {
154-
logrus.Warnf("Failed to encode json: %v", err)
155-
}
153+
}
154+
if err := enc.Encode(stream); err != nil {
155+
logrus.Warnf("Failed to encode json: %v", err)
156156
}
157157
flush()
158158
return

test/apiv2/12-imagesMore.at

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,23 @@ s1=$(jq -r .status <<<"${lines[1]}")
4343
like "$s1" "mytag: digest: sha256:[0-9a-f]\{64\} size: [0-9]\+" \
4444
"Push to local registry: second status line"
4545

46+
# Push to local registry using the libpod endpoint with quiet=false...
47+
# First create a new tag for the image to push
48+
t POST "libpod/images/$IMAGE/tag?repo=localhost:$REGISTRY_PORT/myrepo&tag=quiet-false" 201
49+
50+
t POST "libpod/images/localhost:$REGISTRY_PORT/myrepo:quiet-false/push?tlsVerify=false&quiet=false" 200
51+
52+
# ...and check output. We can't use our built-in checks because this output
53+
# is a sequence of JSON objects, i.e., individual ones, not in a JSON array.
54+
# The lines themselves are valid JSON, but taken together they are not.
55+
readarray lines <<<"$output"
56+
s0=$(jq -r .manifestdigest <<<"${lines[-1]}")
57+
like "$s0" "sha256:[0-9a-f]\{64\}" \
58+
"Push to local registry: last line in push report"
59+
4660
# Untag the image
4761
t POST "libpod/images/$iid/untag?repo=localhost:$REGISTRY_PORT/myrepo&tag=mytag" 201
62+
t POST "libpod/images/$iid/untag?repo=localhost:$REGISTRY_PORT/myrepo&tag=quiet-false" 201
4863

4964
# Try to push non-existing image
5065
t POST "images/localhost:$REGISTRY_PORT/idonotexist/push?tlsVerify=false" 404

0 commit comments

Comments
 (0)