Files
releases/resolver/wasm/wasm.go
T
Dominik Schulz e5427d5adb resolver/wasm: Add NewWithContext to allow passing context (#8499)
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>
2026-04-09 19:10:19 +02:00

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