mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-19 06:51:18 -06:00
e5427d5adb
Previously, initializing a new WASM resolver always used a background context. This prevented callers from passing down an existing context for timeouts, cancellation, or tracing. This change introduces `NewWithContext` in `v1/resolver/wasm` which accepts a context and propagates it to `Entrypoints()`. The existing `New` function has been updated to wrap `NewWithContext` using a background context to preserve backwards compatibility. `LoadWasmResolversFromStore` has been updated to pass the provided context appropriately. Signed-off-by: Dominik Schulz <dschulz@google.com>
23 lines
686 B
Go
23 lines
686 B
Go
// Copyright 2020 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package wasm
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/open-policy-agent/opa/ast"
|
|
v1 "github.com/open-policy-agent/opa/v1/resolver/wasm"
|
|
)
|
|
|
|
// New creates a new Resolver instance which is using the Wasm module
|
|
// policy for the given entrypoint ref.
|
|
func New(entrypoints []ast.Ref, policy []byte, data any) (*Resolver, error) {
|
|
return v1.NewWithContext(context.TODO(), entrypoints, policy, data)
|
|
}
|
|
|
|
// Resolver implements the resolver.Resolver interface
|
|
// using Wasm modules to perform an evaluation.
|
|
type Resolver = v1.Resolver
|