| Index: milo/appengine/console/console.go
|
| diff --git a/milo/appengine/console/console.go b/milo/appengine/console/console.go
|
| index c5338e719a79426ed9436d217aea98ce679bc641..d2fde97a49d47617f1c8ae8327c9957a9f0e8bd4 100644
|
| --- a/milo/appengine/console/console.go
|
| +++ b/milo/appengine/console/console.go
|
| @@ -6,6 +6,7 @@ package console
|
|
|
| import (
|
| "fmt"
|
| + "net/http"
|
| "strings"
|
|
|
| "github.com/luci/luci-go/common/clock"
|
| @@ -13,6 +14,9 @@ import (
|
| "github.com/luci/luci-go/milo/api/resp"
|
| "github.com/luci/luci-go/milo/appengine/backend/git"
|
| "github.com/luci/luci-go/milo/appengine/buildbot"
|
| + "github.com/luci/luci-go/milo/appengine/settings"
|
| + "github.com/luci/luci-go/milo/common/config"
|
| + "github.com/luci/luci-go/server/router"
|
| "golang.org/x/net/context"
|
| )
|
|
|
| @@ -31,10 +35,35 @@ func GetConsoleBuilds(
|
| }
|
| }
|
|
|
| -func console(c context.Context, def *ConsoleDef) (*resp.Console, error) {
|
| +// getConsoleDef finds the console definition as defined by any project.
|
| +// If the user is not a reader of the project, this will return a 404.
|
| +// TODO(hinoka): If the user is not a reader of any of of the builders returned,
|
| +// that builder will be removed from list of results.
|
| +func getConsoleDef(c context.Context, project, name string) (*config.Console, error) {
|
| + cs, err := settings.GetConsole(c, project, name)
|
| + if err != nil {
|
| + return nil, err
|
| + }
|
| + // TODO(hinoka): Remove builders that the user does not have access to.
|
| + return cs, nil
|
| +}
|
| +
|
| +// Main is a redirect handler that redirects the user to the main console for a
|
| +// particular project.
|
| +func Main(ctx *router.Context) {
|
| + w, r, p := ctx.Writer, ctx.Request, ctx.Params
|
| + proj := p.ByName("project")
|
| + http.Redirect(w, r, fmt.Sprintf("/console/%s/main", proj), http.StatusMovedPermanently)
|
| + return
|
| +}
|
| +
|
| +func console(c context.Context, project, name string) (*resp.Console, error) {
|
| tStart := clock.Now(c)
|
| - // Lookup Commits. For this hack, we're just gonna hardcode src.git
|
| - commits, err := git.GetCommits(c, def.Repository, def.Branch, 25)
|
| + def, err := getConsoleDef(c, project, name)
|
| + if err != nil {
|
| + return nil, err
|
| + }
|
| + commits, err := git.GetCommits(c, def.RepoURL, def.Branch, 25)
|
| if err != nil {
|
| return nil, err
|
| }
|
|
|