github status api

This commit is contained in:
Brad Rydzewski 2015-05-09 20:46:32 -07:00
parent 7f162c80b9
commit d07c0cb80d
4 changed files with 17 additions and 12 deletions

View file

@ -38,7 +38,7 @@ func main() {
session := session.New(settings.Session)
eventbus_ := eventbus.New()
queue_ := queue.New()
updater := runner.NewUpdater(eventbus_, store)
updater := runner.NewUpdater(eventbus_, store, remote)
runner_ := runner.Runner{Updater: updater}
go run(&runner_, queue_)

View file

@ -79,14 +79,14 @@ func (r *Runner) Run(w *queue.Work) error {
w.Build.State = common.StateError
w.Build.Finished = time.Now().UTC().Unix()
w.Build.Duration = w.Build.Finished - w.Build.Started
r.SetBuild(w.Repo, w.Build)
r.SetBuild(w.User, w.Repo, w.Build)
}
}()
// marks the build as running
w.Build.Started = time.Now().UTC().Unix()
w.Build.State = common.StateRunning
err := r.SetBuild(w.Repo, w.Build)
err := r.SetBuild(w.User, w.Repo, w.Build)
if err != nil {
return err
}
@ -177,7 +177,7 @@ func (r *Runner) Run(w *queue.Work) error {
break
}
}
err = r.SetBuild(w.Repo, w.Build)
err = r.SetBuild(w.User, w.Repo, w.Build)
if err != nil {
return err
}

View file

@ -3,31 +3,32 @@ package builtin
import (
"encoding/json"
"io"
//"io/ioutil"
"github.com/drone/drone/common"
"github.com/drone/drone/datastore"
"github.com/drone/drone/eventbus"
"github.com/drone/drone/remote"
)
type Updater interface {
SetBuild(*common.Repo, *common.Build) error
SetBuild(*common.User, *common.Repo, *common.Build) error
SetTask(*common.Repo, *common.Build, *common.Task) error
SetLogs(*common.Repo, *common.Build, *common.Task, io.ReadCloser) error
}
// NewUpdater returns an implementation of the Updater interface
// that directly modifies the database and sends messages to the bus.
func NewUpdater(bus eventbus.Bus, store datastore.Datastore) Updater {
return &updater{bus, store}
func NewUpdater(bus eventbus.Bus, store datastore.Datastore, rem remote.Remote) Updater {
return &updater{bus, store, rem}
}
type updater struct {
bus eventbus.Bus
store datastore.Datastore
bus eventbus.Bus
store datastore.Datastore
remote remote.Remote
}
func (u *updater) SetBuild(r *common.Repo, b *common.Build) error {
func (u *updater) SetBuild(user *common.User, r *common.Repo, b *common.Build) error {
err := u.store.SetBuildState(r.FullName, b)
if err != nil {
return err
@ -42,6 +43,11 @@ func (u *updater) SetBuild(r *common.Repo, b *common.Build) error {
u.store.SetRepo(repo)
}
}
// err = u.remote.Status(user, r, b, "")
// if err != nil {
//
// }
}
msg, err := json.Marshal(b)

View file

@ -46,7 +46,6 @@ func GetLogin(c *gin.Context) {
// exit if authorization fails
if c.Writer.Status() != 200 {
log.Errorf("authorization failed.")
return
}