Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package console | |
| 6 | |
| 7 import ( | |
| 8 "net/http" | |
| 9 | |
| 10 "github.com/julienschmidt/httprouter" | |
| 11 "golang.org/x/net/context" | |
| 12 | |
| 13 "github.com/luci/luci-go/appengine/cmd/milo/miloerror" | |
| 14 "github.com/luci/luci-go/appengine/cmd/milo/resp" | |
| 15 "github.com/luci/luci-go/appengine/cmd/milo/settings" | |
| 16 "github.com/luci/luci-go/common/clock" | |
| 17 log "github.com/luci/luci-go/common/logging" | |
| 18 "github.com/luci/luci-go/server/templates" | |
| 19 ) | |
| 20 | |
| 21 type Console struct{} | |
| 22 | |
| 23 // GetTemplateName returns the template name for console pages. | |
| 24 func (x Console) GetTemplateName(t settings.Theme) string { | |
| 25 return "console.html" | |
| 26 } | |
| 27 | |
| 28 type ConsoleDef struct { | |
| 29 Name string | |
| 30 Repository string | |
| 31 Branch string | |
| 32 Builders []resp.BuilderRef | |
| 33 } | |
| 34 | |
| 35 // TODO(hinoka): Move all this into some sorta luci-config thing | |
| 36 var def = ConsoleDef{ | |
| 37 Name: "Chromium Main Waterfall", | |
| 38 Repository: "chromium.googlesource.com/chromium/src", | |
|
nodir
2016/08/03 20:26:17
please make it a valid URL, prepend https://
hinoka
2016/08/03 21:55:40
Done.
| |
| 39 Branch: "master", | |
| 40 Builders: []resp.BuilderRef{ | |
| 41 {"buildbot", "chromium/Android", "clobber", "an"}, | |
| 42 {"buildbot", "chromium/Linux x64", "clobber", "lx"}, | |
| 43 {"buildbot", "chromium/Mac", "clobber", "mc"}, | |
| 44 {"buildbot", "chromium/Win", "clobber|win", "32"}, | |
| 45 {"buildbot", "chromium/Win x64", "clobber|win", "64"}, | |
| 46 {"buildbot", "chromium.linux/Android Arm64 Builder (dbg)", "linu x|android|arm", "db"}, | |
| 47 {"buildbot", "chromium.linux/Android Builder", "linux|android|x8 6", "rl"}, | |
| 48 {"buildbot", "chromium.linux/Android Builder (dbg)", "linux|andr oid|x86", "db"}, | |
| 49 {"buildbot", "chromium.linux/Android Clang Builder (dbg)", "linu x|android|clang", "db"}, | |
| 50 {"buildbot", "chromium.linux/Android Tests", "linux|android|test s", "db"}, | |
| 51 {"buildbot", "chromium.linux/Android Tests (dbg)", "linux|androi d|tests", "db"}, | |
| 52 {"buildbot", "chromium.linux/Blimp Linux (dbg)", "linux", "bl"}, | |
| 53 {"buildbot", "chromium.linux/Cast Android (dbg)", "linux|cast", "an"}, | |
| 54 {"buildbot", "chromium.linux/Cast Linux", "linux|cast", "lx"}, | |
| 55 {"buildbot", "chromium.linux/Linux Builder", "linux|build", "rl" }, | |
| 56 {"buildbot", "chromium.linux/Linux Builder (dbg)", "linux|build" , "d6"}, | |
| 57 {"buildbot", "chromium.linux/Linux Builder (dbg)(32)", "linux|bu ild", "d3"}, | |
| 58 {"buildbot", "chromium.linux/Linux Tests", "linux|test", "rl"}, | |
| 59 {"buildbot", "chromium.linux/Linux Tests (dbg)(1)", "linux|test" , "d1"}, | |
| 60 {"buildbot", "chromium.linux/Linux Tests (dbg)(1)(32)", "linux|t est", "d2"}, | |
| 61 }, | |
| 62 } | |
| 63 | |
| 64 // Render Renders the console page. | |
|
nodir
2016/08/03 20:26:17
s/Renders/renders/
hinoka
2016/08/03 21:55:40
Done.
| |
| 65 func (x Console) Render(c context.Context, r *http.Request, p httprouter.Params) (*templates.Args, error) { | |
| 66 // Ignore, hardcoded for demo | |
| 67 name := p.ByName("name") | |
| 68 if name == "" { | |
| 69 return nil, &miloerror.Error{ | |
| 70 Message: "No name", | |
| 71 Code: http.StatusBadRequest, | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 t3 := clock.Now(c) | |
|
nodir
2016/08/03 20:26:17
rename to start
hinoka
2016/08/03 21:55:40
Removing this, the impl has timing logs
| |
| 76 result, err := console(c, &def) | |
| 77 if err != nil { | |
| 78 return nil, err | |
| 79 } | |
| 80 t4 := clock.Now(c) | |
| 81 log.Debugf(c, "Console took %f seconds.", t4.Sub(t3).Seconds()) | |
|
nodir
2016/08/03 20:26:17
use native representation of durations
nodir
2016/08/03 20:26:17
use clock.Since(c, start)
hinoka
2016/08/03 21:55:40
Removed
| |
| 82 | |
| 83 // Render into the template | |
| 84 args := &templates.Args{ | |
| 85 "Console": result, | |
| 86 } | |
| 87 return args, nil | |
| 88 } | |
| OLD | NEW |