Skip to content

Commit

Permalink
formatting code
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Megarry committed Apr 11, 2017
1 parent 3331873 commit a053a16
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ func newAlertNode(et *ExecutingTask, n *pipeline.AlertNode, l *log.Logger) (an *
c := sensu.HandlerConfig{
Source: s.Source,
}
h, err := et.tm.SensuService.Handler(c, l)
if err != nil {
h, err := et.tm.SensuService.Handler(c, l)
if err != nil {
return nil, errors.Wrap(err, "failed to create sensu alert handler")
}
an.handlers = append(an.handlers, h)
Expand Down
4 changes: 2 additions & 2 deletions pipeline/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,8 @@ type SensuHandler struct {
*AlertNode

// Sensu source in which to post messages.
// If empty uses the Source from the configuration.
Source string
// If empty uses the Source from the configuration.
Source string
}

// Send the alert to Pushover.
Expand Down
2 changes: 1 addition & 1 deletion server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7394,7 +7394,7 @@ func TestServer_AlertHandlers(t *testing.T) {
handler: client.TopicHandler{
Kind: "sensu",
Options: map[string]interface{}{
"Source":"Kapacitor",
"Source": "Kapacitor",
},
},
setup: func(c *server.Config, ha *client.TopicHandler) (context.Context, error) {
Expand Down
16 changes: 8 additions & 8 deletions services/alert/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,14 +771,14 @@ func (s *Service) createHandlerFromSpec(spec HandlerSpec) (handler, error) {
h = NewPublishHandler(c, s.logger)
case "sensu":
c := sensu.HandlerConfig{}
err = decodeOptions(spec.Options, &c)
if err != nil {
return handler{}, err
}
h, err := s.SensuService.Handler(c, s.logger)
if err != nil {
return handler{}, err
}
err = decodeOptions(spec.Options, &c)
if err != nil {
return handler{}, err
}
h, err := s.SensuService.Handler(c, s.logger)
if err != nil {
return handler{}, err
}
h = newExternalHandler(h)
case "slack":
c := slack.HandlerConfig{}
Expand Down
12 changes: 6 additions & 6 deletions services/sensu/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type testOptions struct {
func (s *Service) TestOptions() interface{} {
return &testOptions{
Name: "testName",
Source: "Kapacitor",
Source: "Kapacitor",
Output: "testOutput",
Level: alert.Critical,
}
Expand Down Expand Up @@ -164,7 +164,7 @@ type handler struct {
c HandlerConfig
logger *log.Logger

sourceTmpl *text.Template
sourceTmpl *text.Template
}

func (s *Service) Handler(c HandlerConfig, l *log.Logger) (alert.Handler, error) {
Expand All @@ -173,17 +173,17 @@ func (s *Service) Handler(c HandlerConfig, l *log.Logger) (alert.Handler, error)
return nil, err
}
return &handler{
s: s,
c: c,
logger: l,
s: s,
c: c,
logger: l,
sourceTmpl: srcTmpl,
}, nil
}

func (h *handler) Handle(event alert.Event) {
td := event.TemplateData()
var buf bytes.Buffer
err:= h.sourceTmpl.Execute(&buf, td)
err := h.sourceTmpl.Execute(&buf, td)
if err != nil {
h.logger.Printf("E! failed to evaluate Sensu source template %s: %v", h.c.Source, err)
return
Expand Down

0 comments on commit a053a16

Please sign in to comment.