summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-12-14 18:32:57 +0100
committerGitHub <noreply@github.com>2021-12-14 18:32:57 +0100
commite4e21522d16c530dfa4b816acf53ec46eb5a8095 (patch)
tree840ba752291b868a3bb8964827ebc9d790ed5b5f
parentc134698fa12c793a3a6af7858df7760361ae0a1d (diff)
parent52b12fe98599625a862b6298c654233ce1ae1bbe (diff)
downloadpodman-e4e21522d16c530dfa4b816acf53ec46eb5a8095.tar.gz
podman-e4e21522d16c530dfa4b816acf53ec46eb5a8095.tar.bz2
podman-e4e21522d16c530dfa4b816acf53ec46eb5a8095.zip
Merge pull request #12091 from ananthb/docker-api-compat
Fixes #12063 Add docker compatible output after image build.
-rw-r--r--pkg/api/handlers/compat/images_build.go8
-rw-r--r--test/apiv2/10-images.at14
2 files changed, 21 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index a665be4fb..45e4543a9 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -621,7 +621,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Stream string `json:"stream,omitempty"`
Error *jsonmessage.JSONError `json:"errorDetail,omitempty"`
// NOTE: `error` is being deprecated check https://github.com/moby/moby/blob/master/pkg/jsonmessage/jsonmessage.go#L148
- ErrorMessage string `json:"error,omitempty"` // deprecate this slowly
+ ErrorMessage string `json:"error,omitempty"` // deprecate this slowly
+ Aux json.RawMessage `json:"aux,omitempty"`
}{}
select {
@@ -656,6 +657,11 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
case <-runCtx.Done():
if success {
if !utils.IsLibpodRequest(r) && !query.Quiet {
+ m.Aux = []byte(fmt.Sprintf(`{"ID":"sha256:%s"}`, imageID))
+ if err := enc.Encode(m); err != nil {
+ logrus.Warnf("failed to json encode error %v", err)
+ }
+ m.Aux = nil
m.Stream = fmt.Sprintf("Successfully built %12.12s\n", imageID)
if err := enc.Encode(m); err != nil {
logrus.Warnf("Failed to json encode error %v", err)
diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at
index 85d4d69ed..115332d0c 100644
--- a/test/apiv2/10-images.at
+++ b/test/apiv2/10-images.at
@@ -229,6 +229,20 @@ if ! grep -q '400 Bad Request' "${TMPD}/headers.txt"; then
BUILD_TEST_ERROR="1"
fi
+curl -XPOST --data-binary @<(cat $CONTAINERFILE_TAR) \
+ -H "content-type: application/tar" \
+ --dump-header "${TMPD}/headers.txt" \
+ -o "${TMPD}/response.txt" \
+ "http://$HOST:$PORT/v1.40/build?dockerfile=containerfile" &> /dev/null
+if ! grep -q '200 OK' "${TMPD}/headers.txt"; then
+ echo -e "${red}NOK: Image build from tar failed response was not 200 OK (application/tar)"
+ BUILD_TEST_ERROR="1"
+fi
+if ! grep -qP '^{"aux":{"ID":"sha256:[0-9a-f]{64}"}}$' "${TMPD}/response.txt"; then
+ echo -e "${red}NOK: Image build response does not contain ID"
+ BUILD_TEST_ERROR="1"
+fi
+
t POST libpod/images/prune 200
t POST libpod/images/prune 200 length=0 []