Skip to content

Commit 33d06bf

Browse files
authored
Merge pull request #2610 from crosbymichael/context
Don't use wrappers for grpc metadata
2 parents 9c2aa15 + 7bbda7c commit 33d06bf

11 files changed

Lines changed: 32 additions & 32 deletions

File tree

api/ca.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/control.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/dispatcher.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/health.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/logbroker.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/raft.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/resource.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/watch.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ca/forward.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
// forwardedTLSInfoFromContext obtains forwarded TLS CN/OU from the grpc.MD
1818
// object in ctx.
1919
func forwardedTLSInfoFromContext(ctx context.Context) (remoteAddr string, cn string, org string, ous []string) {
20-
md, _ := metadata.FromContext(ctx)
20+
md, _ := metadata.FromIncomingContext(ctx)
2121
if len(md[remoteAddrKey]) != 0 {
2222
remoteAddr = md[remoteAddrKey][0]
2323
}
@@ -32,7 +32,7 @@ func forwardedTLSInfoFromContext(ctx context.Context) (remoteAddr string, cn str
3232
}
3333

3434
func isForwardedRequest(ctx context.Context) bool {
35-
md, _ := metadata.FromContext(ctx)
35+
md, _ := metadata.FromIncomingContext(ctx)
3636
if len(md[certForwardedKey]) != 1 {
3737
return false
3838
}
@@ -42,7 +42,7 @@ func isForwardedRequest(ctx context.Context) bool {
4242
// WithMetadataForwardTLSInfo reads certificate from context and returns context where
4343
// ForwardCert is set based on original certificate.
4444
func WithMetadataForwardTLSInfo(ctx context.Context) (context.Context, error) {
45-
md, ok := metadata.FromContext(ctx)
45+
md, ok := metadata.FromIncomingContext(ctx)
4646
if !ok {
4747
md = metadata.MD{}
4848
}
@@ -73,5 +73,5 @@ func WithMetadataForwardTLSInfo(ctx context.Context) (context.Context, error) {
7373
md[remoteAddrKey] = []string{peer.Addr.String()}
7474
}
7575

76-
return metadata.NewContext(ctx, md), nil
76+
return metadata.NewOutgoingContext(ctx, md), nil
7777
}

protobuf/plugin/raftproxy/raftproxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ func (g *raftProxyGen) genProxyConstructor(s *descriptor.ServiceDescriptorProto)
3939
return ctx, status.Errorf(codes.InvalidArgument, "remote addr is not found in context")
4040
}
4141
addr := s.ServerTransport().RemoteAddr().String()
42-
md, ok := metadata.FromContext(ctx)
42+
md, ok := metadata.FromIncomingContext(ctx)
4343
if ok && len(md["redirect"]) != 0 {
4444
return ctx, status.Errorf(codes.ResourceExhausted, "more than one redirect to leader from: %s", md["redirect"])
4545
}
4646
if !ok {
4747
md = metadata.New(map[string]string{})
4848
}
4949
md["redirect"] = append(md["redirect"], addr)
50-
return metadata.NewContext(ctx, md), nil
50+
return metadata.NewOutgoingContext(ctx, md), nil
5151
}
5252
remoteMods := []func(context.Context)(context.Context, error){redirectChecker}
5353
remoteMods = append(remoteMods, remoteCtxMod)

0 commit comments

Comments
 (0)