diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-05-24 13:28:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 13:28:29 -0400 |
commit | c6152f40a0d083a894b03ea18f1fabd1b4b68852 (patch) | |
tree | 0b1c8300aa2ea9479c3dab2177c818f69bcb9e43 /pkg | |
parent | 6240783f85ee74c8affac4b36a0db7c272b617de (diff) | |
parent | 2133edb2ca18820585f260db287bd40a57e7b4a2 (diff) | |
download | podman-c6152f40a0d083a894b03ea18f1fabd1b4b68852.tar.gz podman-c6152f40a0d083a894b03ea18f1fabd1b4b68852.tar.bz2 podman-c6152f40a0d083a894b03ea18f1fabd1b4b68852.zip |
Merge pull request #14319 from flouthoc/suppress-aux-on-quiet
compat, build: suppress `step` errors when `quiet=1` is set
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index bcd102901..0a1bc941d 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -674,15 +674,17 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { enc := json.NewEncoder(body) enc.SetEscapeHTML(true) + var stepErrors []string for { - m := struct { + type BuildResponse struct { 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 Aux json.RawMessage `json:"aux,omitempty"` - }{} + } + m := BuildResponse{} select { case e := <-stdout.Chan(): @@ -698,12 +700,27 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } flush() case e := <-auxout.Chan(): - m.Stream = string(e) - if err := enc.Encode(m); err != nil { - stderr.Write([]byte(err.Error())) + if !query.Quiet { + m.Stream = string(e) + if err := enc.Encode(m); err != nil { + stderr.Write([]byte(err.Error())) + } + flush() + } else { + stepErrors = append(stepErrors, string(e)) } - flush() case e := <-stderr.Chan(): + // Docker-API Compat parity : Build failed so + // output all step errors irrespective of quiet + // flag. + for _, stepError := range stepErrors { + t := BuildResponse{} + t.Stream = stepError + if err := enc.Encode(t); err != nil { + stderr.Write([]byte(err.Error())) + } + flush() + } m.ErrorMessage = string(e) m.Error = &jsonmessage.JSONError{ Message: m.ErrorMessage, |