From e01732f85769ac434e2614652aa25cd0ace7a4df Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Thu, 5 Dec 2013 19:03:47 -0700 Subject: [PATCH 1/4] Revert "Add cgroup-bin dependency to our Ubuntu package" This reverts commit c81bb20f5b2b5d86059c6004e60ba23b03d30fe0. After re-reading the documentation: "The Recommends field should list packages that would be found together with this one in all but unusual installations." Thus, "Recommends" is an acceptable place for this dep, and anyone disabling that gets to keep the pieces. The main crux of why this needs to be reverted is because it breaks Debian completely because "lxc" and "cgroup-bin" can't be installed concurrently. --- hack/make/ubuntu | 1 - 1 file changed, 1 deletion(-) diff --git a/hack/make/ubuntu b/hack/make/ubuntu index 258a869c2..578f25455 100644 --- a/hack/make/ubuntu +++ b/hack/make/ubuntu @@ -96,7 +96,6 @@ EOF --depends lxc \ --depends aufs-tools \ --depends iptables \ - --depends cgroup-bin \ --description "$PACKAGE_DESCRIPTION" \ --maintainer "$PACKAGE_MAINTAINER" \ --conflicts lxc-docker-virtual-package \ From 95c0ade04bb8fe95029fed521126e3268a1eda7f Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Fri, 6 Dec 2013 11:55:56 -0800 Subject: [PATCH 2/4] fix jsonmessage in build --- buildfile.go | 4 ++-- commands.go | 2 -- utils/jsonmessage.go | 7 +++++-- utils/streamformatter.go | 12 ++++++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/buildfile.go b/buildfile.go index 170d739ee..adbf98d27 100644 --- a/buildfile.go +++ b/buildfile.go @@ -375,7 +375,7 @@ type StdoutFormater struct { } func (sf *StdoutFormater) Write(buf []byte) (int, error) { - formattedBuf := sf.StreamFormatter.FormatStatus("", "%s", string(buf)) + formattedBuf := sf.StreamFormatter.FormatStream(string(buf)) n, err := sf.Writer.Write(formattedBuf) if n != len(formattedBuf) { return n, io.ErrShortWrite @@ -389,7 +389,7 @@ type StderrFormater struct { } func (sf *StderrFormater) Write(buf []byte) (int, error) { - formattedBuf := sf.StreamFormatter.FormatStatus("", "%s", "\033[91m"+string(buf)+"\033[0m") + formattedBuf := sf.StreamFormatter.FormatStream("\033[91m" + string(buf) + "\033[0m") n, err := sf.Writer.Write(formattedBuf) if n != len(formattedBuf) { return n, io.ErrShortWrite diff --git a/commands.go b/commands.go index b7e7c08ca..48c0241b1 100644 --- a/commands.go +++ b/commands.go @@ -229,8 +229,6 @@ func (cli *DockerCli) CmdBuild(args ...string) error { if context != nil { headers.Set("Content-Type", "application/tar") } - // Temporary hack to fix displayJSON behavior - cli.isTerminal = false err = cli.stream("POST", fmt.Sprintf("/build?%s", v.Encode()), body, cli.out, headers) if jerr, ok := err.(*utils.JSONError); ok { return &utils.StatusError{Status: jerr.Message, StatusCode: jerr.Code} diff --git a/utils/jsonmessage.go b/utils/jsonmessage.go index c36ec2776..82fe631b4 100644 --- a/utils/jsonmessage.go +++ b/utils/jsonmessage.go @@ -66,6 +66,7 @@ func (p *JSONProgress) String() string { } type JSONMessage struct { + Stream string `json:"stream,omitempty"` Status string `json:"status,omitempty"` Progress *JSONProgress `json:"progressDetail,omitempty"` ProgressMessage string `json:"progress,omitempty"` //deprecated @@ -87,7 +88,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error { if isTerminal { // [2K = erase entire current line fmt.Fprintf(out, "%c[2K\r", 27) - endl = "\r\n" + endl = "\r" } if jm.Time != 0 { fmt.Fprintf(out, "[%s] ", time.Unix(jm.Time, 0)) @@ -102,8 +103,10 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error { fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl) } else if jm.ProgressMessage != "" { //deprecated fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl) + } else if jm.Stream != "" { + fmt.Fprintf(out, "%s%s", jm.Stream, endl) } else { - fmt.Fprintf(out, "%s%s", jm.Status, endl) + fmt.Fprintf(out, "%s%s\n", jm.Status, endl) } return nil } diff --git a/utils/streamformatter.go b/utils/streamformatter.go index 60863d2aa..0c41d0bdd 100644 --- a/utils/streamformatter.go +++ b/utils/streamformatter.go @@ -14,6 +14,18 @@ func NewStreamFormatter(json bool) *StreamFormatter { return &StreamFormatter{json, false} } +func (sf *StreamFormatter) FormatStream(str string) []byte { + sf.used = true + if sf.json { + b, err := json.Marshal(&JSONMessage{Stream: str}) + if err != nil { + return sf.FormatError(err) + } + return b + } + return []byte(str + "\r") +} + func (sf *StreamFormatter) FormatStatus(id, format string, a ...interface{}) []byte { sf.used = true str := fmt.Sprintf(format, a...) From 0969be5ddb34ee8a6c09e882d13b1d655e028b23 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Fri, 6 Dec 2013 12:02:21 -0800 Subject: [PATCH 3/4] update doc --- docs/sources/api/docker_remote_api_v1.8.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/api/docker_remote_api_v1.8.rst b/docs/sources/api/docker_remote_api_v1.8.rst index 1e0281761..c9c2473d9 100644 --- a/docs/sources/api/docker_remote_api_v1.8.rst +++ b/docs/sources/api/docker_remote_api_v1.8.rst @@ -1008,8 +1008,8 @@ Build an image from Dockerfile via stdin HTTP/1.1 200 OK Content-Type: application/json - {"status":"Step 1..."} - {"status":"..."} + {"stream":"Step 1..."} + {"stream":"..."} {"error":"Error...", "errorDetail":{"code": 123, "message": "Error..."}} From f28445254f42fd112aba5f2b67ae6169fae29c2b Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Fri, 6 Dec 2013 13:56:09 -0800 Subject: [PATCH 4/4] disable progressbar in non-terminal --- utils/jsonmessage.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/jsonmessage.go b/utils/jsonmessage.go index 82fe631b4..cc467162f 100644 --- a/utils/jsonmessage.go +++ b/utils/jsonmessage.go @@ -89,6 +89,8 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error { // [2K = erase entire current line fmt.Fprintf(out, "%c[2K\r", 27) endl = "\r" + } else if jm.Progress != nil { //disable progressbar in non-terminal + return nil } if jm.Time != 0 { fmt.Fprintf(out, "[%s] ", time.Unix(jm.Time, 0))