| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package logs | 5 package logs |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 ds "github.com/luci/gae/service/datastore" | 8 ds "github.com/luci/gae/service/datastore" |
| 9 "github.com/luci/luci-go/appengine/logdog/coordinator" | 9 "github.com/luci/luci-go/appengine/logdog/coordinator" |
| 10 "github.com/luci/luci-go/appengine/logdog/coordinator/config" | |
| 11 "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1" | 10 "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1" |
| 12 "github.com/luci/luci-go/common/grpcutil" | 11 "github.com/luci/luci-go/common/grpcutil" |
| 13 "github.com/luci/luci-go/common/logdog/types" | 12 "github.com/luci/luci-go/common/logdog/types" |
| 14 log "github.com/luci/luci-go/common/logging" | 13 log "github.com/luci/luci-go/common/logging" |
| 15 "github.com/luci/luci-go/common/proto/logdog/logpb" | 14 "github.com/luci/luci-go/common/proto/logdog/logpb" |
| 16 "golang.org/x/net/context" | 15 "golang.org/x/net/context" |
| 17 "google.golang.org/grpc/codes" | 16 "google.golang.org/grpc/codes" |
| 18 ) | 17 ) |
| 19 | 18 |
| 20 const ( | 19 const ( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 return f(q, false) | 37 return f(q, false) |
| 39 | 38 |
| 40 default: | 39 default: |
| 41 // Default is "both". | 40 // Default is "both". |
| 42 return q | 41 return q |
| 43 } | 42 } |
| 44 } | 43 } |
| 45 | 44 |
| 46 // Query returns log stream paths that match the requested query. | 45 // Query returns log stream paths that match the requested query. |
| 47 func (s *Server) Query(c context.Context, req *logdog.QueryRequest) (*logdog.Que
ryResponse, error) { | 46 func (s *Server) Query(c context.Context, req *logdog.QueryRequest) (*logdog.Que
ryResponse, error) { |
| 47 svc := s.GetServices() |
| 48 |
| 48 // Non-admin users may not request purged results. | 49 // Non-admin users may not request purged results. |
| 49 canSeePurged := true | 50 canSeePurged := true |
| 50 » if err := config.IsAdminUser(c); err != nil { | 51 » if err := coordinator.IsAdminUser(c, svc); err != nil { |
| 51 canSeePurged = false | 52 canSeePurged = false |
| 52 | 53 |
| 53 // Non-admin user. | 54 // Non-admin user. |
| 54 if req.Purged == logdog.QueryRequest_YES { | 55 if req.Purged == logdog.QueryRequest_YES { |
| 55 log.Fields{ | 56 log.Fields{ |
| 56 log.ErrorKey: err, | 57 log.ErrorKey: err, |
| 57 }.Errorf(c, "Non-superuser requested to see purged logs.
Denying.") | 58 }.Errorf(c, "Non-superuser requested to see purged logs.
Denying.") |
| 58 return nil, grpcutil.Errf(codes.InvalidArgument, "non-ad
min user cannot request purged log streams") | 59 return nil, grpcutil.Errf(codes.InvalidArgument, "non-ad
min user cannot request purged log streams") |
| 59 } | 60 } |
| 60 } | 61 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return grpcutil.Internal | 231 return grpcutil.Internal |
| 231 } | 232 } |
| 232 | 233 |
| 233 resp.Streams = streams | 234 resp.Streams = streams |
| 234 if cursor != nil { | 235 if cursor != nil { |
| 235 resp.Next = cursor.String() | 236 resp.Next = cursor.String() |
| 236 } | 237 } |
| 237 | 238 |
| 238 return nil | 239 return nil |
| 239 } | 240 } |
| OLD | NEW |