Chromium Code Reviews| Index: milo/appengine/console/console.go |
| diff --git a/milo/appengine/console/console.go b/milo/appengine/console/console.go |
| index c5338e719a79426ed9436d217aea98ce679bc641..75e11e0f7b7cf80ead43d911264818c2a0a9d1d0 100644 |
| --- a/milo/appengine/console/console.go |
| +++ b/milo/appengine/console/console.go |
| @@ -13,6 +13,8 @@ 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" |
| "golang.org/x/net/context" |
| ) |
| @@ -31,10 +33,31 @@ 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. |
| +// If no name is specified (ie the user hits a url /console/<project>), the |
| +// default console for that project (named "default") will be looked up. |
|
estaab
2016/08/18 23:19:37
Should we 302 redirect to the actual console url s
Ryan Tseng
2016/08/18 23:55:30
Hm okay. In that case i'll name it something nice
|
| +func getConsoleDef(c context.Context, project, name string) (*config.Console, error) { |
| + if name == "" { |
| + name = "default" |
| + } |
| + 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 |
| +} |
| + |
| +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 |
| } |