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/appengine/logdog/coordinator/hierarchy" | 10 "github.com/luci/luci-go/appengine/logdog/coordinator/hierarchy" |
12 "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1" | 11 "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1" |
13 "github.com/luci/luci-go/common/grpcutil" | 12 "github.com/luci/luci-go/common/grpcutil" |
14 log "github.com/luci/luci-go/common/logging" | 13 log "github.com/luci/luci-go/common/logging" |
15 "golang.org/x/net/context" | 14 "golang.org/x/net/context" |
16 "google.golang.org/grpc/codes" | 15 "google.golang.org/grpc/codes" |
17 ) | 16 ) |
18 | 17 |
19 const ( | 18 const ( |
20 // listResultLimit is the maximum number of log streams that will be | 19 // listResultLimit is the maximum number of log streams that will be |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return nil, grpcutil.Errf(codes.PermissionDenied, "non-a
dmin user cannot request purged log paths") | 51 return nil, grpcutil.Errf(codes.PermissionDenied, "non-a
dmin user cannot request purged log paths") |
53 } | 52 } |
54 | 53 |
55 // TODO(dnj): Apply this to the hierarchy request, when purging
is | 54 // TODO(dnj): Apply this to the hierarchy request, when purging
is |
56 // enabled. | 55 // enabled. |
57 } | 56 } |
58 | 57 |
59 l, err := hierarchy.Get(c, hr) | 58 l, err := hierarchy.Get(c, hr) |
60 if err != nil { | 59 if err != nil { |
61 log.WithError(err).Errorf(c, "Failed to get hierarchy listing.") | 60 log.WithError(err).Errorf(c, "Failed to get hierarchy listing.") |
62 » » if err == config.ErrNoAccess { | 61 » » return nil, getGRPCError(c, err) |
63 » » » // User requested a project that either doesn't exist or
they don't have | |
64 » » » // access to. | |
65 » » » return nil, grpcutil.NotFound | |
66 » » } | |
67 » » return nil, grpcutil.InvalidArgument | |
68 } | 62 } |
69 | 63 |
70 resp := logdog.ListResponse{ | 64 resp := logdog.ListResponse{ |
71 Project: string(l.Project), | 65 Project: string(l.Project), |
72 Next: l.Next, | 66 Next: l.Next, |
73 PathBase: string(l.PathBase), | 67 PathBase: string(l.PathBase), |
74 } | 68 } |
75 | 69 |
76 if len(l.Comp) > 0 { | 70 if len(l.Comp) > 0 { |
77 resp.Components = make([]*logdog.ListResponse_Component, len(l.C
omp)) | 71 resp.Components = make([]*logdog.ListResponse_Component, len(l.C
omp)) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 150 } |
157 } | 151 } |
158 } | 152 } |
159 } | 153 } |
160 | 154 |
161 log.Fields{ | 155 log.Fields{ |
162 "count": len(resp.Components), | 156 "count": len(resp.Components), |
163 }.Infof(c, "List completed successfully.") | 157 }.Infof(c, "List completed successfully.") |
164 return &resp, nil | 158 return &resp, nil |
165 } | 159 } |
OLD | NEW |