| 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/settings" |
| 15 "github.com/luci/luci-go/server/templates" |
| 16 ) |
| 17 |
| 18 type Console struct{} |
| 19 |
| 20 // GetTemplateName returns the template name for console pages. |
| 21 func (x Console) GetTemplateName(t settings.Theme) string { |
| 22 return "console.html" |
| 23 } |
| 24 |
| 25 type ConsoleDef struct { |
| 26 Name string |
| 27 Repository string |
| 28 Branch string |
| 29 // TODO(hinoka): Replace this with resp.BuilderRef when tmpBuilderRef is
removed. |
| 30 Builders []tmpBuilderRef |
| 31 } |
| 32 |
| 33 // This is like a resp.BuilderRef, but the Categories are pipe deliminated strin
gs. |
| 34 // This is so that it's easier to define inline here, and this will be deleted o
nce |
| 35 // console definitions are moved to luci-cfg. |
| 36 type tmpBuilderRef struct { |
| 37 Module string |
| 38 Name string |
| 39 Category string |
| 40 ShortName string |
| 41 } |
| 42 |
| 43 // TODO(hinoka): Move all this into some sorta luci-config thing |
| 44 var chromiumConsoleDef = ConsoleDef{ |
| 45 Name: "Chromium Main Waterfall", |
| 46 Repository: "https://chromium.googlesource.com/chromium/src", |
| 47 Branch: "master", |
| 48 Builders: []tmpBuilderRef{ |
| 49 {"buildbot", "chromium/Android", "clobber", "an"}, |
| 50 {"buildbot", "chromium/Linux x64", "clobber", "lx"}, |
| 51 {"buildbot", "chromium/Mac", "clobber", "mc"}, |
| 52 {"buildbot", "chromium/Win", "clobber|win", "32"}, |
| 53 {"buildbot", "chromium/Win x64", "clobber|win", "64"}, |
| 54 {"buildbot", "chromium.linux/Android Arm64 Builder (dbg)", "linu
x|android|arm", "db"}, |
| 55 {"buildbot", "chromium.linux/Android Builder", "linux|android|x8
6", "rl"}, |
| 56 {"buildbot", "chromium.linux/Android Builder (dbg)", "linux|andr
oid|x86", "db"}, |
| 57 {"buildbot", "chromium.linux/Android Clang Builder (dbg)", "linu
x|android|clang", "db"}, |
| 58 {"buildbot", "chromium.linux/Android Tests", "linux|android|test
s", "db"}, |
| 59 {"buildbot", "chromium.linux/Android Tests (dbg)", "linux|androi
d|tests", "db"}, |
| 60 {"buildbot", "chromium.linux/Blimp Linux (dbg)", "linux", "bl"}, |
| 61 {"buildbot", "chromium.linux/Cast Android (dbg)", "linux|cast",
"an"}, |
| 62 {"buildbot", "chromium.linux/Cast Linux", "linux|cast", "lx"}, |
| 63 {"buildbot", "chromium.linux/Linux Builder", "linux|build", "rl"
}, |
| 64 {"buildbot", "chromium.linux/Linux Builder (dbg)", "linux|build"
, "d6"}, |
| 65 {"buildbot", "chromium.linux/Linux Builder (dbg)(32)", "linux|bu
ild", "d3"}, |
| 66 {"buildbot", "chromium.linux/Linux Tests", "linux|test", "rl"}, |
| 67 {"buildbot", "chromium.linux/Linux Tests (dbg)(1)", "linux|test"
, "d1"}, |
| 68 {"buildbot", "chromium.linux/Linux Tests (dbg)(1)(32)", "linux|t
est", "d2"}, |
| 69 }, |
| 70 } |
| 71 |
| 72 // Render renders the console page. |
| 73 func (x Console) Render(c context.Context, r *http.Request, p httprouter.Params)
(*templates.Args, error) { |
| 74 // Ignore, hardcoded for demo |
| 75 name := p.ByName("name") |
| 76 if name == "" { |
| 77 return nil, &miloerror.Error{ |
| 78 Message: "No name", |
| 79 Code: http.StatusBadRequest, |
| 80 } |
| 81 } |
| 82 |
| 83 result, err := console(c, &chromiumConsoleDef) |
| 84 if err != nil { |
| 85 return nil, err |
| 86 } |
| 87 |
| 88 // Render into the template |
| 89 args := &templates.Args{ |
| 90 "Console": result, |
| 91 } |
| 92 return args, nil |
| 93 } |
| OLD | NEW |