diff options
author | Aditya Rajan <arajan@redhat.com> | 2021-11-24 15:51:07 +0530 |
---|---|---|
committer | Aditya Rajan <arajan@redhat.com> | 2021-11-24 15:51:12 +0530 |
commit | 84e81252f23a41cc120e85af56edd114403a9cd1 (patch) | |
tree | 8d47f8042df4748f143f7e523e162e0de0c7e3e9 /pkg/api/handlers/compat | |
parent | 4b014a3aecf9508ed83ae489e188721e6234ccd5 (diff) | |
download | podman-84e81252f23a41cc120e85af56edd114403a9cd1.tar.gz podman-84e81252f23a41cc120e85af56edd114403a9cd1.tar.bz2 podman-84e81252f23a41cc120e85af56edd114403a9cd1.zip |
compat: Add compatiblity with Docker/Moby API for scenarios where build fails
In order to maintain compatiblity with `moby API` we must the field
`errorDetail` which is primary error reporting field with stream.
Currently podman is using `error` which is already deprecated by moby.
Check: https://github.com/moby/moby/blob/master/pkg/jsonmessage/jsonmessage.go#L147
[NO NEW TESTS NEEDED]
We can't test this in podman CI since we dont have a docker client.
Signed-off-by: Aditya Rajan <arajan@redhat.com>
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 7bbc4b99c..ac5934c13 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -24,6 +24,7 @@ import ( "github.com/containers/podman/v3/pkg/auth" "github.com/containers/podman/v3/pkg/channel" "github.com/containers/storage/pkg/archive" + "github.com/docker/docker/pkg/jsonmessage" "github.com/gorilla/schema" "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" @@ -546,8 +547,10 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { for { m := struct { - Stream string `json:"stream,omitempty"` - Error string `json:"error,omitempty"` + 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 }{} select { @@ -570,7 +573,10 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } flush() case e := <-stderr.Chan(): - m.Error = string(e) + m.ErrorMessage = string(e) + m.Error = &jsonmessage.JSONError{ + Message: m.ErrorMessage, + } if err := enc.Encode(m); err != nil { logrus.Warnf("Failed to json encode error %v", err) } |