Index: appengine/logdog/coordinator/endpoints/registration/service.go |
diff --git a/appengine/logdog/coordinator/endpoints/logs/service.go b/appengine/logdog/coordinator/endpoints/registration/service.go |
similarity index 61% |
copy from appengine/logdog/coordinator/endpoints/logs/service.go |
copy to appengine/logdog/coordinator/endpoints/registration/service.go |
index d7000031994f99c8adf8dbefc35b690bd7446902..b9b6daa805ffc001cb59e47cc53b80b97e92c7fa 100644 |
--- a/appengine/logdog/coordinator/endpoints/logs/service.go |
+++ b/appengine/logdog/coordinator/endpoints/registration/service.go |
@@ -1,37 +1,27 @@ |
-// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-package logs |
+package registration |
import ( |
"github.com/golang/protobuf/proto" |
"github.com/luci/luci-go/appengine/logdog/coordinator" |
"github.com/luci/luci-go/appengine/logdog/coordinator/endpoints" |
- "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1" |
+ "github.com/luci/luci-go/common/api/logdog_coordinator/registration/v1" |
"github.com/luci/luci-go/common/config" |
"github.com/luci/luci-go/common/grpcutil" |
log "github.com/luci/luci-go/common/logging" |
"golang.org/x/net/context" |
) |
-// Server is the user-facing log access and query endpoint service. |
-type server struct { |
- // resultLimit is the maximum number of query results to return in a |
- // single query. If zero, the default will be used. |
- // |
- // This is provided for testing purposes. |
- resultLimit int |
-} |
- |
-// New creates a new authenticating LogsServer instance. |
-func New() logdog.LogsServer { |
- return newService(&server{}) |
-} |
+// server is a Cloud Endpoint service supporting log stream registration. |
nodir
2016/05/19 16:43:17
It is not Cloud Endpoints
dnj (Google)
2016/05/19 22:52:04
Done.
|
+type server struct{} |
-func newService(svr *server) logdog.LogsServer { |
- return &logdog.DecoratedLogs{ |
- Service: svr, |
+// New creates a new authenticating ServicesServer instance. |
+func New() logdog.RegistrationServer { |
+ return &logdog.DecoratedRegistration{ |
+ Service: &server{}, |
Prelude: func(c context.Context, methodName string, req proto.Message) (context.Context, error) { |
// Enter a datastore namespace based on the message type. |
// |
@@ -45,7 +35,7 @@ func newService(svr *server) logdog.LogsServer { |
log.Fields{ |
"project": project, |
}.Debugf(c, "User is accessing project.") |
- if err := coordinator.WithProjectNamespace(&c, project); err != nil { |
+ if err := coordinator.WithProjectNamespace(&c, project, coordinator.NamespaceAccessWRITE); err != nil { |
return nil, getGRPCError(c, err) |
} |
} |
@@ -65,20 +55,10 @@ func getGRPCError(c context.Context, err error) error { |
return grpcutil.PermissionDenied |
case coordinator.IsMembershipError(err): |
- log.WithError(err).Errorf(c, "User does not have READ access to project.") |
+ log.WithError(err).Errorf(c, "User does not have WRITE access to project.") |
nodir
2016/05/19 16:43:17
I don't see why this is necessarily WRITE access.
dnj (Google)
2016/05/19 22:52:04
I think it could be useful for debugging, so I'm g
nodir
2016/05/25 17:34:05
Acknowledged.
|
return grpcutil.PermissionDenied |
default: |
return grpcutil.Internal |
} |
} |
- |
-func (s *server) limit(v int, d int) int { |
- if s.resultLimit > 0 { |
- d = s.resultLimit |
- } |
- if v <= 0 || v > d { |
- return d |
- } |
- return v |
-} |