| Index: appengine/cmd/milo/buildbot/pubsub.go
|
| diff --git a/appengine/cmd/milo/buildbot/pubsub.go b/appengine/cmd/milo/buildbot/pubsub.go
|
| index 0f883fa30c9d74c8f5a1d4c121a453adffdc3628..d4d88df1de90584a66e698b1d21beef076b26bdf 100644
|
| --- a/appengine/cmd/milo/buildbot/pubsub.go
|
| +++ b/appengine/cmd/milo/buildbot/pubsub.go
|
| @@ -3,29 +3,28 @@
|
| // that can be found in the LICENSE file.
|
|
|
| package buildbot
|
|
|
| import (
|
| "bytes"
|
| "compress/gzip"
|
| "compress/zlib"
|
| "encoding/base64"
|
| "encoding/json"
|
| - "net/http"
|
| "time"
|
|
|
| "github.com/luci/gae/service/datastore"
|
| "github.com/luci/luci-go/common/clock"
|
| "github.com/luci/luci-go/common/iotools"
|
| log "github.com/luci/luci-go/common/logging"
|
| + "github.com/luci/luci-go/server/router"
|
|
|
| - "github.com/julienschmidt/httprouter"
|
| "golang.org/x/net/context"
|
| )
|
|
|
| var (
|
| // subName is the name of the pubsub subscription that milo is expecting.
|
| // TODO(hinoka): This should be read from luci-config.
|
| subName = "projects/luci-milo/subscriptions/buildbot-public"
|
| )
|
|
|
| type pubSubMessage struct {
|
| @@ -111,22 +110,23 @@ func unmarshal(
|
| bm.Builds = append(bm.Builds, build)
|
| slave.RunningbuildsMap[build.Buildername] = append(
|
| slave.RunningbuildsMap[build.Buildername], build.Number)
|
| }
|
| slave.Runningbuilds = nil
|
| }
|
| return bm.Builds, bm.Master, nil
|
| }
|
|
|
| // PubSubHandler is a webhook that stores the builds coming in from pubsub.
|
| -func PubSubHandler(
|
| - c context.Context, h http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| +func PubSubHandler(ctx *router.Context) {
|
| + c, h, r := ctx.Context, ctx.Writer, ctx.Request
|
| +
|
| msg := pubSubSubscription{}
|
| defer r.Body.Close()
|
| dec := json.NewDecoder(r.Body)
|
| if err := dec.Decode(&msg); err != nil {
|
| log.WithError(err).Errorf(
|
| c, "Could not decode message. %s", err)
|
| h.WriteHeader(200) // This is a hard failure, we don't want PubSub to retry.
|
| return
|
| }
|
| if msg.Subscription != subName {
|
|
|