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

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: Comments. 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 bb32f5d992f48fba4aedf73d705e52f1621b3fbf..54a85376288ba79922fba782ae16b3dca20d6b21 100644
--- a/appengine/logdog/coordinator/endpoints/services/registerStream.go
+++ b/appengine/logdog/coordinator/endpoints/services/registerStream.go
@@ -15,6 +15,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"
@@ -48,8 +49,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,
@@ -65,7 +67,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)
@@ -78,13 +81,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)
@@ -143,7 +148,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