mirror of
https://github.com/containers/podman.git
synced 2025-06-22 18:08:11 +08:00
Merge pull request #12405 from flouthoc/compat-build-error
compat: Add compatiblity with `Docker/Moby` API for scenarios where build fails.
This commit is contained in:
@ -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"
|
||||
@ -547,7 +548,9 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
||||
for {
|
||||
m := struct {
|
||||
Stream string `json:"stream,omitempty"`
|
||||
Error string `json:"error,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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user