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

Side by Side Diff: logdog/appengine/coordinator/context.go

Issue 2575383002: Add server/cache support to gaeconfig. (Closed)
Patch Set: Un-collapse. 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 coordinator 5 package coordinator
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 9
10 "github.com/luci/gae/service/info" 10 "github.com/luci/gae/service/info"
11 luciConfig "github.com/luci/luci-go/common/config"
12 log "github.com/luci/luci-go/common/logging" 11 log "github.com/luci/luci-go/common/logging"
13 "github.com/luci/luci-go/grpc/grpcutil" 12 "github.com/luci/luci-go/grpc/grpcutil"
14 "github.com/luci/luci-go/logdog/api/config/svcconfig" 13 "github.com/luci/luci-go/logdog/api/config/svcconfig"
15 "github.com/luci/luci-go/logdog/appengine/coordinator/config" 14 "github.com/luci/luci-go/logdog/appengine/coordinator/config"
16 "github.com/luci/luci-go/luci_config/common/cfgtypes" 15 "github.com/luci/luci-go/luci_config/common/cfgtypes"
16 "github.com/luci/luci-go/luci_config/server/cfgclient"
17 "github.com/luci/luci-go/server/auth" 17 "github.com/luci/luci-go/server/auth"
18 "github.com/luci/luci-go/server/auth/identity" 18 "github.com/luci/luci-go/server/auth/identity"
19 19
20 "golang.org/x/net/context" 20 "golang.org/x/net/context"
21 "google.golang.org/grpc/codes" 21 "google.golang.org/grpc/codes"
22 ) 22 )
23 23
24 // NamespaceAccessType specifies the type of namespace access that is being 24 // NamespaceAccessType specifies the type of namespace access that is being
25 // requested for WithProjectNamespace. 25 // requested for WithProjectNamespace.
26 type NamespaceAccessType int 26 type NamespaceAccessType int
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 // Returns the project config, or "read denied" error if the project doe s not 100 // Returns the project config, or "read denied" error if the project doe s not
101 // exist. 101 // exist.
102 getProjectConfig := func() (*svcconfig.ProjectConfig, error) { 102 getProjectConfig := func() (*svcconfig.ProjectConfig, error) {
103 pcfg, err := GetServices(ctx).ProjectConfig(ctx, project) 103 pcfg, err := GetServices(ctx).ProjectConfig(ctx, project)
104 switch err { 104 switch err {
105 case nil: 105 case nil:
106 // Successfully loaded project config. 106 // Successfully loaded project config.
107 return pcfg, nil 107 return pcfg, nil
108 108
109 » » case luciConfig.ErrNoConfig, config.ErrInvalidConfig: 109 » » case cfgclient.ErrNoConfig, config.ErrInvalidConfig:
110 // If the configuration request was valid, but no config uration could be 110 // If the configuration request was valid, but no config uration could be
111 // loaded, treat this as the user not having READ access to the project. 111 // loaded, treat this as the user not having READ access to the project.
112 // Otherwise, the user could use this error response to confirm a 112 // Otherwise, the user could use this error response to confirm a
113 // project's existence. 113 // project's existence.
114 log.Fields{ 114 log.Fields{
115 log.ErrorKey: err, 115 log.ErrorKey: err,
116 "project": project, 116 "project": project,
117 }.Errorf(ctx, "Could not load config for project.") 117 }.Errorf(ctx, "Could not load config for project.")
118 return nil, getAccessDeniedError() 118 return nil, getAccessDeniedError()
119 119
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // namespace conforming to ProjectNamespace. If this is not the case, this 190 // namespace conforming to ProjectNamespace. If this is not the case, this
191 // method will panic. 191 // method will panic.
192 func Project(c context.Context) cfgtypes.ProjectName { 192 func Project(c context.Context) cfgtypes.ProjectName {
193 ns := info.GetNamespace(c) 193 ns := info.GetNamespace(c)
194 project := ProjectFromNamespace(ns) 194 project := ProjectFromNamespace(ns)
195 if project != "" { 195 if project != "" {
196 return project 196 return project
197 } 197 }
198 panic(fmt.Errorf("current namespace %q does not begin with project names pace prefix (%q)", ns, projectNamespacePrefix)) 198 panic(fmt.Errorf("current namespace %q does not begin with project names pace prefix (%q)", ns, projectNamespacePrefix))
199 } 199 }
OLDNEW
« no previous file with comments | « logdog/appengine/coordinator/config/projects.go ('k') | logdog/appengine/coordinator/context_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698