From dbdbe9547c7def93c6fe69d8fab1e31cd5db65d3 Mon Sep 17 00:00:00 2001 From: hc-github-team-secure-vault-core <82990506+hc-github-team-secure-vault-core@users.noreply.github.com> Date: Mon, 13 Feb 2023 14:34:42 -0500 Subject: [PATCH] backport of commit 063a782e2d6485c6e74870215fc12c565d89954e (#19169) Co-authored-by: Christopher Swenson --- helper/namespace/namespace.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/helper/namespace/namespace.go b/helper/namespace/namespace.go index 93d68622dec5..c1226a5547f9 100644 --- a/helper/namespace/namespace.go +++ b/helper/namespace/namespace.go @@ -61,11 +61,8 @@ func RootContext(ctx context.Context) context.Context { return ContextWithNamespace(ctx, RootNamespace) } -// This function caches the ns to avoid doing a .Value lookup over and over, -// because it's called a *lot* in the request critical path. .Value is -// concurrency-safe so uses some kind of locking/atomicity, but it should never -// be read before first write, plus we don't believe this will be called from -// different goroutines, so it should be safe. +// FromContext retrieves the namespace from a context, or an error +// if there is no namespace in the context. func FromContext(ctx context.Context) (*Namespace, error) { if ctx == nil { return nil, errors.New("context was nil")