summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/limits
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-08-21 16:18:31 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-09 17:53:10 -0700
commitac83a6a5ed237e0ddcb473b1cbc2e30d8e6c6740 (patch)
treea10d4332bd2958268e0bb9026629d6cfe3b65469 /pkg/sentry/limits
parent3810a62b3a2e6bb55c3d030e15ba09665f2f91b3 (diff)
Internal change.
PiperOrigin-RevId: 327892274
Diffstat (limited to 'pkg/sentry/limits')
-rw-r--r--pkg/sentry/limits/context.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/sentry/limits/context.go b/pkg/sentry/limits/context.go
index 77e1fe217..0bade6e57 100644
--- a/pkg/sentry/limits/context.go
+++ b/pkg/sentry/limits/context.go
@@ -33,3 +33,12 @@ func FromContext(ctx context.Context) *LimitSet {
}
return nil
}
+
+// FromContextOrDie returns FromContext(ctx) if the latter is not nil.
+// Otherwise, panic is triggered.
+func FromContextOrDie(ctx context.Context) *LimitSet {
+ if v := ctx.Value(CtxLimits); v != nil {
+ return v.(*LimitSet)
+ }
+ panic("failed to create limit set from context")
+}