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..323eb8dee816a6119fd17e6cf152d8acf80fed75 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,29 @@ 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. |
| +// If the user is not a reader of any of of the builders returned, |
|
estaab
2016/08/18 15:51:46
Can you move the TODO up here so it's clear that i
Ryan Tseng
2016/08/18 18:12:45
Done.
|
| +// that builder will be removed from list of results. |
| +func getConsoleDef(c context.Context, project, name string) (*config.Console, error) { |
| + if name == "" { |
| + name = "default" |
|
estaab
2016/08/18 15:51:46
Can you mention something about this? What is the
Ryan Tseng
2016/08/18 18:12:45
Done.
|
| + } |
| + 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 |
| } |