MCPcopy
hub / github.com/containerd/containerd / Namespace

Function Namespace

pkg/namespaces/context.go:58–66  ·  view source on GitHub ↗

Namespace returns the namespace from the context. The namespace is not guaranteed to be valid.

(ctx context.Context)

Source from the content-addressed store, hash-verified

56//
57// The namespace is not guaranteed to be valid.
58func Namespace(ctx context.Context) (string, bool) {
59 namespace, ok := ctx.Value(namespaceKey{}).(string)
60 if !ok {
61 if namespace, ok = fromGRPCHeader(ctx); !ok {
62 return fromTTRPCHeader(ctx)
63 }
64 }
65 return namespace, ok
66}
67
68// NamespaceRequired returns the valid namespace from the context or an error.
69func NamespaceRequired(ctx context.Context) (string, error) {

Callers 15

unaryMethod · 0.92
streamMethod · 0.92
WithNewSpecFunction · 0.92
TestMainFunction · 0.92
addSnapshotLeaseFunction · 0.92
removeSnapshotLeaseFunction · 0.92
addContentLeaseFunction · 0.92
removeContentLeaseFunction · 0.92
addIngestLeaseFunction · 0.92
removeIngestLeaseFunction · 0.92
addImageLeaseFunction · 0.92
removeImageLeaseFunction · 0.92

Calls 2

fromTTRPCHeaderFunction · 0.85
fromGRPCHeaderFunction · 0.70

Tested by 5

TestMainFunction · 0.74
checkContentLeasedFunction · 0.74
checkIngestLeasedFunction · 0.74
TestContextFunction · 0.56
TestNamespaceFromEnvFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…