| OLD | NEW |
| 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 logdog | 5 package logdog |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/http" | 8 "net/http" |
| 9 "strings" | 9 "strings" |
| 10 | 10 |
| 11 "github.com/julienschmidt/httprouter" | 11 "github.com/julienschmidt/httprouter" |
| 12 "github.com/luci/luci-go/common/config" | |
| 13 log "github.com/luci/luci-go/common/logging" | 12 log "github.com/luci/luci-go/common/logging" |
| 14 "github.com/luci/luci-go/grpc/prpc" | 13 "github.com/luci/luci-go/grpc/prpc" |
| 15 "github.com/luci/luci-go/logdog/client/coordinator" | 14 "github.com/luci/luci-go/logdog/client/coordinator" |
| 16 "github.com/luci/luci-go/logdog/common/types" | 15 "github.com/luci/luci-go/logdog/common/types" |
| 16 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 17 "github.com/luci/luci-go/milo/appengine/settings" | 17 "github.com/luci/luci-go/milo/appengine/settings" |
| 18 "github.com/luci/luci-go/milo/common/miloerror" | 18 "github.com/luci/luci-go/milo/common/miloerror" |
| 19 "github.com/luci/luci-go/server/auth" | 19 "github.com/luci/luci-go/server/auth" |
| 20 "github.com/luci/luci-go/server/templates" | 20 "github.com/luci/luci-go/server/templates" |
| 21 | 21 |
| 22 "golang.org/x/net/context" | 22 "golang.org/x/net/context" |
| 23 ) | 23 ) |
| 24 | 24 |
| 25 // AnnotationStream is a ThemedHandler that renders a LogDog Milo annotation | 25 // AnnotationStream is a ThemedHandler that renders a LogDog Milo annotation |
| 26 // protobuf stream. | 26 // protobuf stream. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 44 if err != nil { | 44 if err != nil { |
| 45 log.WithError(err).Errorf(c, "Failed to get transport for LogDog
server.") | 45 log.WithError(err).Errorf(c, "Failed to get transport for LogDog
server.") |
| 46 return nil, &miloerror.Error{ | 46 return nil, &miloerror.Error{ |
| 47 Code: http.StatusInternalServerError, | 47 Code: http.StatusInternalServerError, |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 as := annotationStreamRequest{ | 51 as := annotationStreamRequest{ |
| 52 AnnotationStream: s, | 52 AnnotationStream: s, |
| 53 | 53 |
| 54 » » project: config.ProjectName(p.ByName("project")), | 54 » » project: cfgtypes.ProjectName(p.ByName("project")), |
| 55 path: types.StreamPath(strings.Trim(p.ByName("path"), "/")), | 55 path: types.StreamPath(strings.Trim(p.ByName("path"), "/")), |
| 56 host: req.FormValue("host"), | 56 host: req.FormValue("host"), |
| 57 } | 57 } |
| 58 if err := as.normalize(); err != nil { | 58 if err := as.normalize(); err != nil { |
| 59 return nil, err | 59 return nil, err |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Setup our LogDog client. | 62 // Setup our LogDog client. |
| 63 as.logDogClient = coordinator.NewClient(&prpc.Client{ | 63 as.logDogClient = coordinator.NewClient(&prpc.Client{ |
| 64 C: &http.Client{ | 64 C: &http.Client{ |
| 65 Transport: t, | 65 Transport: t, |
| 66 }, | 66 }, |
| 67 Host: as.host, | 67 Host: as.host, |
| 68 }) | 68 }) |
| 69 | 69 |
| 70 // Load the Milo annotation protobuf from the annotation stream. | 70 // Load the Milo annotation protobuf from the annotation stream. |
| 71 if err := as.load(c); err != nil { | 71 if err := as.load(c); err != nil { |
| 72 return nil, err | 72 return nil, err |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Convert the Milo Annotation protobuf to Milo objects. | 75 // Convert the Milo Annotation protobuf to Milo objects. |
| 76 return &templates.Args{ | 76 return &templates.Args{ |
| 77 "Build": as.toMiloBuild(c), | 77 "Build": as.toMiloBuild(c), |
| 78 }, nil | 78 }, nil |
| 79 } | 79 } |
| OLD | NEW |