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

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

Issue 2675493003: milo: Use service interface for swarming. (Closed)
Patch Set: Created 3 years, 11 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/swarming/html.go
diff --git a/milo/appengine/swarming/html.go b/milo/appengine/swarming/html.go
index b612723b60c6a9927f70a632e6b18ad930c5720e..5fb3bea18f00ef2a13ea75e620131be35a50dbe1 100644
--- a/milo/appengine/swarming/html.go
+++ b/milo/appengine/swarming/html.go
@@ -18,17 +18,21 @@ import (
"github.com/luci/luci-go/server/templates"
)
-func getServer(r *http.Request) string {
+const (
+ defaultSwarmingServer = "chromium-swarm.appspot.com"
+ defaultSwarmingDevServer = "chromium-swarm-dev.appspot.com"
+)
+
+func getSwarmingService(c context.Context, r *http.Request) (swarmingService, error) {
server := r.FormValue("server")
// TODO(hinoka): configure this mapping in luci-config
switch server {
case "":
- return "chromium-swarm.appspot.com"
+ server = defaultSwarmingServer
hinoka 2017/02/03 01:02:23 This is only used once, lets not do this. It's in
dnj 2017/02/03 01:04:56 The final CL in the chain uses it, too.
case "dev":
- return "chromium-swarm-dev.appspot.com"
- default:
- return server
+ server = defaultSwarmingDevServer
}
+ return newProdService(c, server)
}
// Log is for fetching logs from swarming.
@@ -59,7 +63,12 @@ func (l Log) Render(c context.Context, r *http.Request, p httprouter.Params) (*t
}
}
- log, closed, err := swarmingBuildLogImpl(c, getServer(r), id, logname)
+ sf, err := getSwarmingService(c, r)
+ if err != nil {
+ return nil, convertErr(err)
+ }
+
+ log, closed, err := swarmingBuildLogImpl(c, sf, id, logname)
if err != nil {
return nil, convertErr(err)
}
@@ -87,7 +96,12 @@ func (b Build) Render(c context.Context, r *http.Request, p httprouter.Params) (
}
}
- result, err := swarmingBuildImpl(c, r.URL.String(), getServer(r), id)
+ sf, err := getSwarmingService(c, r)
+ if err != nil {
+ return nil, convertErr(err)
+ }
+
+ result, err := swarmingBuildImpl(c, sf, r.URL.String(), id)
if err != nil {
return nil, convertErr(err)
}

Powered by Google App Engine
This is Rietveld 408576698