Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1503)

Unified Diff: milo/appengine/console/console.go

Issue 2238883003: Milo: Use luci-cfg for defining projects and console view. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: review Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | milo/appengine/console/html.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
« no previous file with comments | « no previous file | milo/appengine/console/html.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698