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

Unified Diff: milo/appengine/logdog/http.go

Issue 2695383002: milo: Enable Swarming LogDog log loading. (Closed)
Patch Set: Comments, fix links. 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/logdog/build.go ('k') | milo/appengine/swarming/build.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/logdog/http.go
diff --git a/milo/appengine/logdog/http.go b/milo/appengine/logdog/http.go
index 0084d5f06716ef7aec524eb457ee1ca71123e7c0..43190b9074cec535178ce247f70b67646da313e2 100644
--- a/milo/appengine/logdog/http.go
+++ b/milo/appengine/logdog/http.go
@@ -60,7 +60,7 @@ func (s *AnnotationStreamHandler) Render(c context.Context, req *http.Request, p
}
// Load the Milo annotation protobuf from the annotation stream.
- if _, err := as.Load(c); err != nil {
+ if _, err := as.Fetch(c); err != nil {
return nil, err
}
@@ -70,11 +70,26 @@ func (s *AnnotationStreamHandler) Render(c context.Context, req *http.Request, p
}, nil
}
+func resolveHost(host string) (string, error) {
+ // Resolveour our Host, and validate it against a host whitelist.
+ switch host {
+ case "":
+ return defaultLogDogHost, nil
+ case defaultLogDogHost, "luci-logdog-dev.appspot.com":
+ return host, nil
+ default:
+ return "", errors.Reason("host %(host)q is not whitelisted").
+ D("host", host).
+ Err()
+ }
+}
+
// NewClient generates a new LogDog client that issues requests on behalf of the
// current user.
func NewClient(c context.Context, host string) (*coordinator.Client, error) {
- if host == "" {
- host = defaultLogDogHost
+ var err error
+ if host, err = resolveHost(host); err != nil {
+ return nil, err
}
// Initialize the LogDog client authentication.
« no previous file with comments | « milo/appengine/logdog/build.go ('k') | milo/appengine/swarming/build.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698