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

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

Issue 2675493003: milo: Use service interface for swarming. (Closed)
Patch Set: Update fetch signature Created 3 years, 10 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
« no previous file with comments | « milo/appengine/swarming/expectations/build-unicode.json ('k') | milo/appengine/swarming/html_data.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/swarming/html.go
diff --git a/milo/appengine/swarming/html.go b/milo/appengine/swarming/html.go
index b612723b60c6a9927f70a632e6b18ad930c5720e..abc08c2ebfef720aac42efed291c08b7a4b9ad79 100644
--- a/milo/appengine/swarming/html.go
+++ b/milo/appengine/swarming/html.go
@@ -18,19 +18,38 @@ 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 getSwarmingHost(r *http.Request) string {
server := r.FormValue("server")
- // TODO(hinoka): configure this mapping in luci-config
switch server {
case "":
- return "chromium-swarm.appspot.com"
+ return defaultSwarmingServer
case "dev":
- return "chromium-swarm-dev.appspot.com"
+ return defaultSwarmingDevServer
default:
return server
}
}
+func getSwarmingService(c context.Context, host string) (swarmingService, error) {
+ switch host {
+ // TODO(hinoka): configure this mapping in luci-config
+ case defaultSwarmingServer, defaultSwarmingDevServer,
+ "cast-swarming.appspot.com":
+ return newProdService(c, host)
+
+ default:
+ return nil, &miloerror.Error{
+ Message: "unregistered Swarming host",
+ Code: http.StatusNotFound,
+ }
+ }
+}
+
// Log is for fetching logs from swarming.
type Log struct{}
@@ -59,7 +78,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, getSwarmingHost(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 +111,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, getSwarmingHost(r))
+ if err != nil {
+ return nil, convertErr(err)
+ }
+
+ result, err := swarmingBuildImpl(c, sf, r.URL.String(), id)
if err != nil {
return nil, convertErr(err)
}
« no previous file with comments | « milo/appengine/swarming/expectations/build-unicode.json ('k') | milo/appengine/swarming/html_data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698