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

Unified Diff: milo/appengine/buildbucket/html.go

Issue 2765383002: Milo: Move instance configuration to luci-config (Closed)
Patch Set: Created 3 years, 9 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
Index: milo/appengine/buildbucket/html.go
diff --git a/milo/appengine/buildbucket/html.go b/milo/appengine/buildbucket/html.go
index cf074c5b92ab1da1ff8df8ff53dfc391da8bf232..ca484e5e428835e44f6fc08e46994e445bb6c379 100644
--- a/milo/appengine/buildbucket/html.go
+++ b/milo/appengine/buildbucket/html.go
@@ -5,22 +5,31 @@
package buildbucket
import (
+ "context"
"errors"
"net/http"
"github.com/julienschmidt/httprouter"
+ "github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/milo/appengine/common"
+ "github.com/luci/luci-go/milo/common/config"
"github.com/luci/luci-go/server/router"
"github.com/luci/luci-go/server/templates"
)
-// TODO(nodir): move this value to luci-config.
-const defaultServer = "cr-buildbucket.appspot.com"
+func parseBuilderQuery(c context.Context, r *http.Request, p httprouter.Params) (
+ query builderQuery, err error) {
-func parseBuilderQuery(r *http.Request, p httprouter.Params) (query builderQuery, err error) {
query.Server = r.FormValue("server")
if query.Server == "" {
- query.Server = defaultServer
+ var settings *config.Settings
+ settings, err = common.GetSettings(c)
+ if err != nil || settings.Buildbucket == nil {
+ logging.WithError(err).Errorf(c, "failed to get settings")
+ err = errors.New("no server specified and buildbucket settings not configured")
+ return
+ }
+ query.Server = settings.Buildbucket.Host
}
query.Bucket = p.ByName("bucket")
@@ -45,7 +54,7 @@ func parseBuilderQuery(r *http.Request, p httprouter.Params) (query builderQuery
// Note: The builder html template contains self links to "?limit=123", which could
// potentially override any other request parameters set.
func BuilderHandler(c *router.Context) {
- query, err := parseBuilderQuery(c.Request, c.Params)
+ query, err := parseBuilderQuery(c.Context, c.Request, c.Params)
if err != nil {
common.ErrorPage(c, http.StatusBadRequest, err.Error())
return

Powered by Google App Engine
This is Rietveld 408576698