| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 logs | 5 package logs |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "github.com/golang/protobuf/proto" | 8 "github.com/golang/protobuf/proto" |
| 9 "github.com/luci/luci-go/common/config" | |
| 10 log "github.com/luci/luci-go/common/logging" | 9 log "github.com/luci/luci-go/common/logging" |
| 11 "github.com/luci/luci-go/grpc/grpcutil" | 10 "github.com/luci/luci-go/grpc/grpcutil" |
| 12 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/logs/v1" | 11 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/logs/v1" |
| 13 "github.com/luci/luci-go/logdog/appengine/coordinator" | 12 "github.com/luci/luci-go/logdog/appengine/coordinator" |
| 14 "github.com/luci/luci-go/logdog/appengine/coordinator/endpoints" | 13 "github.com/luci/luci-go/logdog/appengine/coordinator/endpoints" |
| 14 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 15 | 15 |
| 16 "golang.org/x/net/context" | 16 "golang.org/x/net/context" |
| 17 "google.golang.org/grpc/codes" | 17 "google.golang.org/grpc/codes" |
| 18 ) | 18 ) |
| 19 | 19 |
| 20 // Server is the user-facing log access and query endpoint service. | 20 // Server is the user-facing log access and query endpoint service. |
| 21 type server struct { | 21 type server struct { |
| 22 // resultLimit is the maximum number of query results to return in a | 22 // resultLimit is the maximum number of query results to return in a |
| 23 // single query. If zero, the default will be used. | 23 // single query. If zero, the default will be used. |
| 24 // | 24 // |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 Service: svr, | 36 Service: svr, |
| 37 Prelude: func(c context.Context, methodName string, req proto.Me
ssage) (context.Context, error) { | 37 Prelude: func(c context.Context, methodName string, req proto.Me
ssage) (context.Context, error) { |
| 38 // Enter a datastore namespace based on the message type
. | 38 // Enter a datastore namespace based on the message type
. |
| 39 // | 39 // |
| 40 // We use a type switch here because this is a shared de
corator. All user | 40 // We use a type switch here because this is a shared de
corator. All user |
| 41 // mesages must implement ProjectBoundMessage. | 41 // mesages must implement ProjectBoundMessage. |
| 42 pbm, ok := req.(endpoints.ProjectBoundMessage) | 42 pbm, ok := req.(endpoints.ProjectBoundMessage) |
| 43 if ok { | 43 if ok { |
| 44 // Enter the requested project namespace. This v
alidates that the | 44 // Enter the requested project namespace. This v
alidates that the |
| 45 // current user has READ access. | 45 // current user has READ access. |
| 46 » » » » project := config.ProjectName(pbm.GetMessageProj
ect()) | 46 » » » » project := cfgtypes.ProjectName(pbm.GetMessagePr
oject()) |
| 47 if project == "" { | 47 if project == "" { |
| 48 return nil, grpcutil.Errf(codes.InvalidA
rgument, "project is required") | 48 return nil, grpcutil.Errf(codes.InvalidA
rgument, "project is required") |
| 49 } | 49 } |
| 50 | 50 |
| 51 log.Fields{ | 51 log.Fields{ |
| 52 "project": project, | 52 "project": project, |
| 53 }.Debugf(c, "User is accessing project.") | 53 }.Debugf(c, "User is accessing project.") |
| 54 if err := coordinator.WithProjectNamespace(&c, p
roject, coordinator.NamespaceAccessREAD); err != nil { | 54 if err := coordinator.WithProjectNamespace(&c, p
roject, coordinator.NamespaceAccessREAD); err != nil { |
| 55 return nil, getGRPCError(err) | 55 return nil, getGRPCError(err) |
| 56 } | 56 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 78 | 78 |
| 79 func (s *server) limit(v int, d int) int { | 79 func (s *server) limit(v int, d int) int { |
| 80 if s.resultLimit > 0 { | 80 if s.resultLimit > 0 { |
| 81 d = s.resultLimit | 81 d = s.resultLimit |
| 82 } | 82 } |
| 83 if v <= 0 || v > d { | 83 if v <= 0 || v > d { |
| 84 return d | 84 return d |
| 85 } | 85 } |
| 86 return v | 86 return v |
| 87 } | 87 } |
| OLD | NEW |