Merge pull request #3098 from creack/bump_v0.7.1
Bump v0.7.1
diff --git a/buildfile.go b/buildfile.go
index 170d739..adbf98d 100644
--- a/buildfile.go
+++ b/buildfile.go
@@ -375,7 +375,7 @@
}
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 @@
}
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 b7e7c08..48c0241 100644
--- a/commands.go
+++ b/commands.go
@@ -229,8 +229,6 @@
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/docs/sources/api/docker_remote_api_v1.8.rst b/docs/sources/api/docker_remote_api_v1.8.rst
index 1e02817..c9c2473 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 @@
HTTP/1.1 200 OK
Content-Type: application/json
- {"status":"Step 1..."}
- {"status":"..."}
+ {"stream":"Step 1..."}
+ {"stream":"..."}
{"error":"Error...", "errorDetail":{"code": 123, "message": "Error..."}}
diff --git a/hack/make/ubuntu b/hack/make/ubuntu
index 258a869..578f254 100644
--- a/hack/make/ubuntu
+++ b/hack/make/ubuntu
@@ -96,7 +96,6 @@
--depends lxc \
--depends aufs-tools \
--depends iptables \
- --depends cgroup-bin \
--description "$PACKAGE_DESCRIPTION" \
--maintainer "$PACKAGE_MAINTAINER" \
--conflicts lxc-docker-virtual-package \
diff --git a/utils/jsonmessage.go b/utils/jsonmessage.go
index c36ec27..cc46716 100644
--- a/utils/jsonmessage.go
+++ b/utils/jsonmessage.go
@@ -66,6 +66,7 @@
}
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,9 @@
if isTerminal {
// <ESC>[2K = erase entire current line
fmt.Fprintf(out, "%c[2K\r", 27)
- endl = "\r\n"
+ 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))
@@ -102,8 +105,10 @@
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 60863d2..0c41d0b 100644
--- a/utils/streamformatter.go
+++ b/utils/streamformatter.go
@@ -14,6 +14,18 @@
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...)