mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
52381423d3
Signed-off-by: Stephan Renatus <stephan@styra.com>
18 lines
358 B
Go
18 lines
358 B
Go
package ast
|
|
|
|
import "context"
|
|
|
|
type regoCompileCtx struct{}
|
|
|
|
func WithCompiler(ctx context.Context, c *Compiler) context.Context {
|
|
return context.WithValue(ctx, regoCompileCtx{}, c)
|
|
}
|
|
|
|
func CompilerFromContext(ctx context.Context) (*Compiler, bool) {
|
|
if ctx == nil {
|
|
return nil, false
|
|
}
|
|
v, ok := ctx.Value(regoCompileCtx{}).(*Compiler)
|
|
return v, ok
|
|
}
|