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

Side by Side Diff: milo/appengine/job_source/buildbot/html.go

Issue 2949783002: [milo] appengine/* -> * (Closed)
Patch Set: rebase Created 3 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 buildbot
6
7 import (
8 "fmt"
9 "net/http"
10 "strconv"
11
12 "github.com/luci/luci-go/milo/appengine/common"
13 "github.com/luci/luci-go/server/router"
14 "github.com/luci/luci-go/server/templates"
15 )
16
17 // BuildHandler Renders the buildbot build page.
18 func BuildHandler(c *router.Context) {
19 master := c.Params.ByName("master")
20 if master == "" {
21 common.ErrorPage(c, http.StatusBadRequest, "No master specified" )
22 return
23 }
24 builder := c.Params.ByName("builder")
25 if builder == "" {
26 common.ErrorPage(c, http.StatusBadRequest, "No builder specified ")
27 return
28 }
29 buildNum := c.Params.ByName("build")
30 if buildNum == "" {
31 common.ErrorPage(c, http.StatusBadRequest, "No build number")
32 return
33 }
34 num, err := strconv.Atoi(buildNum)
35 if err != nil {
36 common.ErrorPage(c, http.StatusBadRequest,
37 fmt.Sprintf("%s does not look like a number", buildNum))
38 return
39 }
40
41 result, err := Build(c.Context, master, builder, num)
42 if err != nil {
43 var code int
44 switch err {
45 case errBuildNotFound:
46 code = http.StatusNotFound
47 case errNotAuth:
48 code = http.StatusUnauthorized
49 default:
50 code = http.StatusInternalServerError
51 }
52 common.ErrorPage(c, code, err.Error())
53 return
54 }
55
56 templates.MustRender(c.Context, c.Writer, "pages/build.html", templates. Args{
57 "Build": result,
58 })
59 }
60
61 // BuilderHandler renders the buildbot builder page.
62 // Note: The builder html template contains self links to "?limit=123", which co uld
63 // potentially override any other request parameters set.
64 func BuilderHandler(c *router.Context) {
65 master := c.Params.ByName("master")
66 if master == "" {
67 common.ErrorPage(c, http.StatusBadRequest, "No master specified" )
68 return
69 }
70 builder := c.Params.ByName("builder")
71 if builder == "" {
72 common.ErrorPage(c, http.StatusBadRequest, "No builder specified ")
73 return
74 }
75 limit, err := common.GetLimit(c.Request)
76 if err != nil {
77 common.ErrorPage(c, http.StatusBadRequest, err.Error())
78 return
79 }
80 if limit < 0 {
81 limit = 25
82 }
83 cursor := c.Request.FormValue("cursor")
84
85 result, err := builderImpl(c.Context, master, builder, limit, cursor)
86 _, notFound := err.(errBuilderNotFound)
87 switch {
88 case err == nil:
89 templates.MustRender(c.Context, c.Writer, "pages/builder.html", templates.Args{
90 "Builder": result,
91 })
92 case err == errNotAuth:
93 common.ErrorPage(c, http.StatusUnauthorized, err.Error())
94 case notFound:
95 common.ErrorPage(c, http.StatusNotFound, err.Error())
96 default: // err != nil
97 common.ErrorPage(c, http.StatusInternalServerError, err.Error())
98 }
99 return
100 }
OLDNEW
« no previous file with comments | « milo/appengine/job_source/buildbot/grpc_test.go ('k') | milo/appengine/job_source/buildbot/html_data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698