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

Side by Side Diff: logdog/appengine/coordinator/endpoints/registration/service.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 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 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 registration 5 package registration
6 6
7 import ( 7 import (
8 "github.com/golang/protobuf/proto" 8 "github.com/golang/protobuf/proto"
9 "github.com/luci/luci-go/common/config"
10 log "github.com/luci/luci-go/common/logging" 9 log "github.com/luci/luci-go/common/logging"
11 "github.com/luci/luci-go/grpc/grpcutil" 10 "github.com/luci/luci-go/grpc/grpcutil"
12 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/registration/v 1" 11 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/registration/v 1"
13 "github.com/luci/luci-go/logdog/appengine/coordinator" 12 "github.com/luci/luci-go/logdog/appengine/coordinator"
14 "github.com/luci/luci-go/logdog/appengine/coordinator/endpoints" 13 "github.com/luci/luci-go/logdog/appengine/coordinator/endpoints"
14 "github.com/luci/luci-go/luci_config/common/cfgtypes"
15 15
16 "golang.org/x/net/context" 16 "golang.org/x/net/context"
17 "google.golang.org/grpc/codes" 17 "google.golang.org/grpc/codes"
18 ) 18 )
19 19
20 // server is a service supporting log stream registration. 20 // server is a service supporting log stream registration.
21 type server struct{} 21 type server struct{}
22 22
23 // New creates a new authenticating ServicesServer instance. 23 // New creates a new authenticating ServicesServer instance.
24 func New() logdog.RegistrationServer { 24 func New() logdog.RegistrationServer {
25 return &logdog.DecoratedRegistration{ 25 return &logdog.DecoratedRegistration{
26 Service: &server{}, 26 Service: &server{},
27 Prelude: func(c context.Context, methodName string, req proto.Me ssage) (context.Context, error) { 27 Prelude: func(c context.Context, methodName string, req proto.Me ssage) (context.Context, error) {
28 // Enter a datastore namespace based on the message type . 28 // Enter a datastore namespace based on the message type .
29 // 29 //
30 // We use a type switch here because this is a shared de corator. All user 30 // We use a type switch here because this is a shared de corator. All user
31 // mesages must implement ProjectBoundMessage. 31 // mesages must implement ProjectBoundMessage.
32 pbm, ok := req.(endpoints.ProjectBoundMessage) 32 pbm, ok := req.(endpoints.ProjectBoundMessage)
33 if ok { 33 if ok {
34 // Enter the requested project namespace. This v alidates that the 34 // Enter the requested project namespace. This v alidates that the
35 // current user has READ access. 35 // current user has READ access.
36 » » » » project := config.ProjectName(pbm.GetMessageProj ect()) 36 » » » » project := cfgtypes.ProjectName(pbm.GetMessagePr oject())
37 if project == "" { 37 if project == "" {
38 return nil, grpcutil.Errf(codes.InvalidA rgument, "project is required") 38 return nil, grpcutil.Errf(codes.InvalidA rgument, "project is required")
39 } 39 }
40 40
41 log.Fields{ 41 log.Fields{
42 "project": project, 42 "project": project,
43 }.Debugf(c, "User is accessing project.") 43 }.Debugf(c, "User is accessing project.")
44 if err := coordinator.WithProjectNamespace(&c, p roject, coordinator.NamespaceAccessWRITE); err != nil { 44 if err := coordinator.WithProjectNamespace(&c, p roject, coordinator.NamespaceAccessWRITE); err != nil {
45 return nil, getGRPCError(err) 45 return nil, getGRPCError(err)
46 } 46 }
(...skipping 11 matching lines...) Expand all
58 58
59 case grpcutil.Code(err) != codes.Unknown: 59 case grpcutil.Code(err) != codes.Unknown:
60 // If this is already a gRPC error, return it directly. 60 // If this is already a gRPC error, return it directly.
61 return err 61 return err
62 62
63 default: 63 default:
64 // Generic empty internal error. 64 // Generic empty internal error.
65 return grpcutil.Internal 65 return grpcutil.Internal
66 } 66 }
67 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698