MCPcopy
hub / github.com/containerd/containerd / withGRPCNamespaceHeader

Function withGRPCNamespaceHeader

pkg/namespaces/grpc.go:32–45  ·  view source on GitHub ↗

NOTE(stevvooe): We can stub this file out if we don't want a grpc dependency here.

(ctx context.Context, namespace string)

Source from the content-addressed store, hash-verified

30// NOTE(stevvooe): We can stub this file out if we don't want a grpc dependency here.
31
32func withGRPCNamespaceHeader(ctx context.Context, namespace string) context.Context {
33 // also store on the grpc headers so it gets picked up by any clients that
34 // are using this.
35 nsheader := metadata.Pairs(GRPCHeader, namespace)
36 md, ok := metadata.FromOutgoingContext(ctx) // merge with outgoing context.
37 if !ok {
38 md = nsheader
39 } else {
40 // order ensures the latest is first in this list.
41 md = metadata.Join(nsheader, md)
42 }
43
44 return metadata.NewOutgoingContext(ctx, md)
45}
46
47func fromGRPCHeader(ctx context.Context) (string, bool) {
48 // try to extract for use in grpc servers.

Callers 1

WithNamespaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…