diff --git a/drone.go b/drone.go index b296f1a8a..30b391059 100644 --- a/drone.go +++ b/drone.go @@ -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_) diff --git a/runner/builtin/runner.go b/runner/builtin/runner.go index bcbe7bce1..c56ee7fc9 100644 --- a/runner/builtin/runner.go +++ b/runner/builtin/runner.go @@ -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 } diff --git a/runner/builtin/updater.go b/runner/builtin/updater.go index 5eae27ce9..a22460e97 100644 --- a/runner/builtin/updater.go +++ b/runner/builtin/updater.go @@ -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) diff --git a/server/login.go b/server/login.go index 6a9c8a41b..f34c3702d 100644 --- a/server/login.go +++ b/server/login.go @@ -46,7 +46,6 @@ func GetLogin(c *gin.Context) { // exit if authorization fails if c.Writer.Status() != 200 { - log.Errorf("authorization failed.") return }