Skip to content

Commit

Permalink
send a build:create error event on failed; add time to event
Browse files Browse the repository at this point in the history
  • Loading branch information
nzoschke committed Apr 25, 2016
1 parent 6cc1c0f commit cb0ea5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/controllers/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ func BuildUpdate(rw http.ResponseWriter, r *http.Request) *httperr.Error {
return httperr.Server(err)
}

if b.Status == "failed" {
provider.EventSend(&structs.Event{
Action: "build:create",
Data: map[string]string{
"app": b.App,
"id": b.Id,
},
}, fmt.Errorf(b.Reason))
}

return RenderJson(rw, b)
}

Expand Down
2 changes: 2 additions & 0 deletions api/provider/aws/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"os"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sns"
Expand All @@ -27,6 +28,7 @@ func (p *AWSProvider) EventSend(e *structs.Event, err error) error {
log := logger.New("ns=kernel")

e.Status = "success"
e.Timestamp = time.Now().UTC()

if err != nil {
e.Data["message"] = err.Error()
Expand Down

0 comments on commit cb0ea5b

Please sign in to comment.