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

Side by Side Diff: milo/appengine/buildbucket/html.go

Issue 2765383002: Milo: Move instance configuration to luci-config (Closed)
Patch Set: Review Created 3 years, 8 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
« no previous file with comments | « milo/appengine/buildbucket/builder_test.go ('k') | milo/appengine/swarming/build.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package buildbucket 5 package buildbucket
6 6
7 import ( 7 import (
8 "context"
8 "errors" 9 "errors"
9 "net/http" 10 "net/http"
10 11
11 "github.com/julienschmidt/httprouter" 12 "github.com/julienschmidt/httprouter"
12 "github.com/luci/luci-go/milo/appengine/common" 13 "github.com/luci/luci-go/milo/appengine/common"
13 "github.com/luci/luci-go/server/router" 14 "github.com/luci/luci-go/server/router"
14 "github.com/luci/luci-go/server/templates" 15 "github.com/luci/luci-go/server/templates"
15 ) 16 )
16 17
17 // TODO(nodir): move this value to luci-config. 18 func parseBuilderQuery(c context.Context, r *http.Request, p httprouter.Params) (
18 const defaultServer = "cr-buildbucket.appspot.com" 19 » query builderQuery, err error) {
19
20 func parseBuilderQuery(r *http.Request, p httprouter.Params) (query builderQuery , err error) {
21 » query.Server = r.FormValue("server")
22 » if query.Server == "" {
23 » » query.Server = defaultServer
24 » }
25 20
26 query.Bucket = p.ByName("bucket") 21 query.Bucket = p.ByName("bucket")
27 if query.Bucket == "" { 22 if query.Bucket == "" {
28 err = errors.New("No bucket") 23 err = errors.New("No bucket")
29 return 24 return
30 } 25 }
31 26
32 query.Builder = p.ByName("builder") 27 query.Builder = p.ByName("builder")
33 if query.Builder == "" { 28 if query.Builder == "" {
34 err = errors.New("No builder") 29 err = errors.New("No builder")
35 return 30 return
36 } 31 }
37 32
38 // limit is a name of the query string parameter for specifying 33 // limit is a name of the query string parameter for specifying
39 // maximum number of builds to show. 34 // maximum number of builds to show.
40 query.Limit, err = common.GetLimit(r) 35 query.Limit, err = common.GetLimit(r)
41 return 36 return
42 } 37 }
43 38
44 // BuilderHandler renders the builder view page. 39 // BuilderHandler renders the builder view page.
45 // Note: The builder html template contains self links to "?limit=123", which co uld 40 // Note: The builder html template contains self links to "?limit=123", which co uld
46 // potentially override any other request parameters set. 41 // potentially override any other request parameters set.
47 func BuilderHandler(c *router.Context) { 42 func BuilderHandler(c *router.Context) {
48 » query, err := parseBuilderQuery(c.Request, c.Params) 43 » query, err := parseBuilderQuery(c.Context, c.Request, c.Params)
49 if err != nil { 44 if err != nil {
50 common.ErrorPage(c, http.StatusBadRequest, err.Error()) 45 common.ErrorPage(c, http.StatusBadRequest, err.Error())
51 return 46 return
52 } 47 }
53 48
54 result, err := builderImpl(c.Context, query) 49 result, err := builderImpl(c.Context, query)
55 if err != nil { 50 if err != nil {
56 common.ErrorPage(c, http.StatusInternalServerError, err.Error()) 51 common.ErrorPage(c, http.StatusInternalServerError, err.Error())
57 return 52 return
58 } 53 }
59 54
60 templates.MustRender(c.Context, c.Writer, "pages/builder.html", template s.Args{ 55 templates.MustRender(c.Context, c.Writer, "pages/builder.html", template s.Args{
61 "Builder": result, 56 "Builder": result,
62 }) 57 })
63 } 58 }
OLDNEW
« no previous file with comments | « milo/appengine/buildbucket/builder_test.go ('k') | milo/appengine/swarming/build.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698