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

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

Issue 2626433004: Move "common/config" common types into cfgtypes. (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
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 hierarchy 5 package hierarchy
6 6
7 import ( 7 import (
8 "sort" 8 "sort"
9 9
10 "github.com/luci/luci-go/common/config"
11 log "github.com/luci/luci-go/common/logging" 10 log "github.com/luci/luci-go/common/logging"
12 "github.com/luci/luci-go/grpc/grpcutil" 11 "github.com/luci/luci-go/grpc/grpcutil"
13 "github.com/luci/luci-go/logdog/appengine/coordinator" 12 "github.com/luci/luci-go/logdog/appengine/coordinator"
13 "github.com/luci/luci-go/luci_config/common/cfgtypes"
14 14
15 "golang.org/x/net/context" 15 "golang.org/x/net/context"
16 ) 16 )
17 17
18 func getProjects(c context.Context, r *Request) (*List, error) { 18 func getProjects(c context.Context, r *Request) (*List, error) {
19 // None of the projects are streams. 19 // None of the projects are streams.
20 var l List 20 var l List
21 if r.StreamOnly { 21 if r.StreamOnly {
22 return &l, nil 22 return &l, nil
23 } 23 }
24 24
25 // Get all user-accessible active projects. 25 // Get all user-accessible active projects.
26 allPcfgs, err := coordinator.ActiveUserProjects(c) 26 allPcfgs, err := coordinator.ActiveUserProjects(c)
27 if err != nil { 27 if err != nil {
28 // If there is an error, we will refrain from filtering projects . 28 // If there is an error, we will refrain from filtering projects .
29 log.WithError(err).Warningf(c, "Failed to get user project list. ") 29 log.WithError(err).Warningf(c, "Failed to get user project list. ")
30 return nil, grpcutil.Internal 30 return nil, grpcutil.Internal
31 } 31 }
32 32
33 projects := make(projectNameSlice, 0, len(allPcfgs)) 33 projects := make(projectNameSlice, 0, len(allPcfgs))
34 for project := range allPcfgs { 34 for project := range allPcfgs {
35 projects = append(projects, project) 35 projects = append(projects, project)
36 } 36 }
37 sort.Sort(projects) 37 sort.Sort(projects)
38 38
39 » next := config.ProjectName(r.Next) 39 » next := cfgtypes.ProjectName(r.Next)
40 skip := r.Skip 40 skip := r.Skip
41 for _, proj := range projects { 41 for _, proj := range projects {
42 // Implement "Next" cursor. If set, don't do anything until we'v e seen it. 42 // Implement "Next" cursor. If set, don't do anything until we'v e seen it.
43 if next != "" { 43 if next != "" {
44 if proj == next { 44 if proj == next {
45 next = "" 45 next = ""
46 } 46 }
47 continue 47 continue
48 } 48 }
49 49
(...skipping 10 matching lines...) Expand all
60 // Implement limit. 60 // Implement limit.
61 if r.Limit > 0 && len(l.Comp) >= r.Limit { 61 if r.Limit > 0 && len(l.Comp) >= r.Limit {
62 l.Next = string(proj) 62 l.Next = string(proj)
63 break 63 break
64 } 64 }
65 } 65 }
66 66
67 return &l, nil 67 return &l, nil
68 } 68 }
69 69
70 // projectNameSlice is a sortable slice of config.ProjectName. 70 // projectNameSlice is a sortable slice of cfgtypes.ProjectName.
71 type projectNameSlice []config.ProjectName 71 type projectNameSlice []cfgtypes.ProjectName
72 72
73 func (s projectNameSlice) Len() int { return len(s) } 73 func (s projectNameSlice) Len() int { return len(s) }
74 func (s projectNameSlice) Less(i, j int) bool { return s[i] < s[j] } 74 func (s projectNameSlice) Less(i, j int) bool { return s[i] < s[j] }
75 func (s projectNameSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 75 func (s projectNameSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
OLDNEW
« no previous file with comments | « logdog/appengine/coordinator/hierarchy/hierarchy_test.go ('k') | logdog/appengine/coordinator/project.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698