diff --git a/vendor/gopkg.in/clog.v1/clog.go b/vendor/gopkg.in/clog.v1/clog.go index c1797fa9c..5236cae6f 100644 --- a/vendor/gopkg.in/clog.v1/clog.go +++ b/vendor/gopkg.in/clog.v1/clog.go @@ -24,7 +24,7 @@ import ( ) const ( - _VERSION = "1.1.0" + _VERSION = "1.1.1" ) // Version returns current version of the package. diff --git a/vendor/gopkg.in/clog.v1/slack.go b/vendor/gopkg.in/clog.v1/slack.go index 93c5e651f..5ce655776 100644 --- a/vendor/gopkg.in/clog.v1/slack.go +++ b/vendor/gopkg.in/clog.v1/slack.go @@ -16,22 +16,24 @@ package clog import ( "bytes" + "encoding/json" "errors" "fmt" "io/ioutil" "net/http" ) +type slackAttachment struct { + Text string `json:"text"` + Color string `json:"color"` +} + +type slackPayload struct { + Attachments []slackAttachment `json:"attachments"` +} + const ( - SLACK = "slack" - _SLACK_ATTACHMENT = `{ - "attachments": [ - { - "text": "%s", - "color": "%s" - } - ] -}` + SLACK = "slack" ) var slackColors = []string{ @@ -92,13 +94,30 @@ func (s *slack) ExchangeChans(errorChan chan<- error) chan *Message { return s.msgChan } -func buildSlackAttachment(msg *Message) string { - return fmt.Sprintf(_SLACK_ATTACHMENT, msg.Body, slackColors[msg.Level]) +func buildSlackPayload(msg *Message) (string, error) { + payload := slackPayload{ + Attachments: []slackAttachment{ + { + Text: msg.Body, + Color: slackColors[msg.Level], + }, + }, + } + p, err := json.Marshal(&payload) + if err != nil { + return "", err + } + return string(p), nil } func (s *slack) write(msg *Message) { - attachment := buildSlackAttachment(msg) - resp, err := http.Post(s.url, "application/json", bytes.NewReader([]byte(attachment))) + payload, err := buildSlackPayload(msg) + if err != nil { + s.errorChan <- fmt.Errorf("slack.buildSlackPayload: %v", err) + return + } + + resp, err := http.Post(s.url, "application/json", bytes.NewReader([]byte(payload))) if err != nil { s.errorChan <- fmt.Errorf("slack: %v", err) } diff --git a/vendor/vendor.json b/vendor/vendor.json index 3ae74e56d..ac1843604 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -567,10 +567,10 @@ "revisionTime": "2015-09-24T05:17:56Z" }, { - "checksumSHA1": "ZJBrUSDBKgkXID1MVRkXSTlmOh4=", + "checksumSHA1": "AbDfvggt92trYSRhGRqXW5uQ4aU=", "path": "gopkg.in/clog.v1", - "revision": "ff5a366d133e02b3d411dbe3854ebd912a434c7f", - "revisionTime": "2017-03-23T22:33:02Z" + "revision": "8492a6faa632c31ba82f562b53b4a6e5eacf2732", + "revisionTime": "2017-05-26T21:48:39Z" }, { "checksumSHA1": "LIu3jihd3edOyIsJJK3V6vx2UZg=",