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

Unified Diff: appengine/logdog/coordinator/endpoints/services/registerStream.go

Issue 1910923002: LogDog: Add project namespace to service endpoint. (Closed) Base URL: https://github.com/luci/luci-go@logdog-project-coordinator-backend
Patch Set: Updates, works. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: appengine/logdog/coordinator/endpoints/services/registerStream.go
diff --git a/appengine/logdog/coordinator/endpoints/services/registerStream.go b/appengine/logdog/coordinator/endpoints/services/registerStream.go
index 4256e861b43aa8e69274d1c5069722184511becc..dd13ff58015b4df3e78365896384faecba633c17 100644
--- a/appengine/logdog/coordinator/endpoints/services/registerStream.go
+++ b/appengine/logdog/coordinator/endpoints/services/registerStream.go
@@ -14,6 +14,7 @@ import (
"github.com/luci/luci-go/appengine/tumble"
"github.com/luci/luci-go/common/api/logdog_coordinator/services/v1"
"github.com/luci/luci-go/common/clock"
+ "github.com/luci/luci-go/common/config"
"github.com/luci/luci-go/common/grpcutil"
"github.com/luci/luci-go/common/logdog/types"
log "github.com/luci/luci-go/common/logging"
@@ -47,8 +48,9 @@ func matchesLogStream(r *logdog.RegisterStreamRequest, ls *coordinator.LogStream
return nil
}
-func loadLogStreamState(ls *coordinator.LogStream) *logdog.LogStreamState {
+func loadLogStreamState(project config.ProjectName, ls *coordinator.LogStream) *logdog.LogStreamState {
st := logdog.LogStreamState{
+ Project: string(project),
Path: string(ls.Path()),
ProtoVersion: ls.ProtoVersion,
TerminalIndex: ls.TerminalIndex,
@@ -64,7 +66,8 @@ func loadLogStreamState(ls *coordinator.LogStream) *logdog.LogStreamState {
// RegisterStream is an idempotent stream state register operation.
func (s *server) RegisterStream(c context.Context, req *logdog.RegisterStreamRequest) (*logdog.RegisterStreamResponse, error) {
log.Fields{
- "path": req.Path,
+ "project": req.Project,
+ "path": req.Path,
}.Infof(c, "Registration request for log stream.")
path := types.StreamPath(req.Path)
@@ -77,13 +80,15 @@ func (s *server) RegisterStream(c context.Context, req *logdog.RegisterStreamReq
return nil, grpcutil.Errf(codes.InvalidArgument, "No protobuf version supplied.")
case req.ProtoVersion != logpb.Version:
return nil, grpcutil.Errf(codes.InvalidArgument, "Unrecognized protobuf version.")
- case len(req.Secret) != types.StreamSecretLength:
- return nil, grpcutil.Errf(codes.InvalidArgument, "Invalid secret length (%d != %d)",
- len(req.Secret), types.StreamSecretLength)
case req.Desc == nil:
return nil, grpcutil.Errf(codes.InvalidArgument, "Missing log stream descriptor.")
}
+ secret := types.PrefixSecret(req.Secret)
+ if err := secret.Validate(); err != nil {
+ return nil, grpcutil.Errf(codes.InvalidArgument, "Invalid prefix secret: %s", err)
+ }
+
prefix, name := path.Split()
if err := req.Desc.Validate(true); err != nil {
return nil, grpcutil.Errf(codes.InvalidArgument, "Invalid log stream descriptor: %s", err)
@@ -122,7 +127,7 @@ func (s *server) RegisterStream(c context.Context, req *logdog.RegisterStreamReq
}
return &logdog.RegisterStreamResponse{
- State: loadLogStreamState(ls),
+ State: loadLogStreamState(coordinator.Project(c), ls),
Secret: ls.Secret,
}, nil
}

Powered by Google App Engine
This is Rietveld 408576698