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

Side by Side Diff: logdog/appengine/coordinator/hierarchy/project.go

Issue 2991253004: [logdog] Remove list functionality. (Closed)
Patch Set: fix test Created 3 years, 4 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 unified diff | Download patch
« no previous file with comments | « logdog/appengine/coordinator/hierarchy/hierarchy_test.go ('k') | logdog/client/cli/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The LUCI Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package hierarchy
16
17 import (
18 log "github.com/luci/luci-go/common/logging"
19 "github.com/luci/luci-go/grpc/grpcutil"
20 "github.com/luci/luci-go/logdog/appengine/coordinator/config"
21 "github.com/luci/luci-go/luci_config/common/cfgtypes"
22
23 "golang.org/x/net/context"
24 )
25
26 func getProjects(c context.Context, r *Request) (*List, error) {
27 // None of the projects are streams.
28 var l List
29 if r.StreamOnly {
30 return &l, nil
31 }
32
33 // Get all user-accessible active projects.
34 projects, err := config.ActiveUserProjects(c)
35 if err != nil {
36 // If there is an error, we will refrain from filtering projects .
37 log.WithError(err).Warningf(c, "Failed to get user project list. ")
38 return nil, grpcutil.Internal
39 }
40
41 next := cfgtypes.ProjectName(r.Next)
42 skip := r.Skip
43 for _, proj := range projects {
44 // Implement "Next" cursor. If set, don't do anything until we'v e seen it.
45 if next != "" {
46 if proj == next {
47 next = ""
48 }
49 continue
50 }
51
52 // Implement skip.
53 if skip > 0 {
54 skip--
55 continue
56 }
57
58 l.Comp = append(l.Comp, &ListComponent{
59 Name: string(proj),
60 })
61
62 // Implement limit.
63 if r.Limit > 0 && len(l.Comp) >= r.Limit {
64 l.Next = string(proj)
65 break
66 }
67 }
68
69 return &l, nil
70 }
OLDNEW
« no previous file with comments | « logdog/appengine/coordinator/hierarchy/hierarchy_test.go ('k') | logdog/client/cli/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698