summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/limits
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-08-21 23:23:24 +0000
committergVisor bot <gvisor-bot@google.com>2020-08-21 23:23:24 +0000
commit47705f49649a22f89cb93d15389f6c69b3813f12 (patch)
tree1ea717ec2d9e91d86e682148659ed05959101e8a /pkg/sentry/limits
parent748bc2111b26653c6f01713437e52807dfce32ce (diff)
parent23070b2e5fab3c777dfd6389b80472ba9d58572e (diff)
Merge release-20200810.0-86-g23070b2e5 (automated)
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")
+}