Merge pull request #1392 from MHBauer/issue1367

add newline to event json to match docker
This commit is contained in:
Alexandre Beslic 2015-11-23 09:54:00 -08:00
commit 62c5d4b47a
2 changed files with 4 additions and 2 deletions

View File

@ -10,6 +10,8 @@ import (
"github.com/docker/swarm/cluster"
)
const eventFmt string = "{%q:%q,%q:%q,%q:%q,%q:%d,%q:{%q:%q,%q:%q,%q:%q,%q:%q}}\n"
// EventsHandler broadcasts events to multiple client listeners.
type eventsHandler struct {
sync.RWMutex
@ -66,7 +68,7 @@ func (eh *eventsHandler) cleanupHandler(remoteAddr string) {
func (eh *eventsHandler) Handle(e *cluster.Event) error {
eh.RLock()
str := fmt.Sprintf("{%q:%q,%q:%q,%q:%q,%q:%d,%q:{%q:%q,%q:%q,%q:%q,%q:%q}}",
str := fmt.Sprintf(eventFmt,
"status", e.Status,
"id", e.Id,
"from", e.From+" node:"+e.Engine.Name,

View File

@ -42,7 +42,7 @@ func TestHandle(t *testing.T) {
assert.NoError(t, eh.Handle(event))
str := fmt.Sprintf("{%q:%q,%q:%q,%q:%q,%q:%d,%q:{%q:%q,%q:%q,%q:%q,%q:%q}}",
str := fmt.Sprintf(eventFmt,
"status", "status",
"id", "id",
"from", "from node:node_name",