Enhance wasm plugins

Co-authored-by: Michael <[michael.matur@gmail.com](mailto:michael.matur@gmail.com)>
This commit is contained in:
Julien Salleyron 2024-06-25 09:58:04 +02:00 committed by GitHub
parent 983940ae60
commit e7d1a98c5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 329 additions and 26 deletions

View file

@ -52,7 +52,7 @@ func NewBuilder(client *Client, plugins map[string]Descriptor, localPlugins map[
switch manifest.Type {
case typeMiddleware:
middleware, err := newMiddlewareBuilder(logCtx, client.GoPath(), manifest, desc.ModuleName)
middleware, err := newMiddlewareBuilder(logCtx, client.GoPath(), manifest, desc.ModuleName, desc.Settings)
if err != nil {
return nil, err
}
@ -87,7 +87,7 @@ func NewBuilder(client *Client, plugins map[string]Descriptor, localPlugins map[
switch manifest.Type {
case typeMiddleware:
middleware, err := newMiddlewareBuilder(logCtx, localGoPath, manifest, desc.ModuleName)
middleware, err := newMiddlewareBuilder(logCtx, localGoPath, manifest, desc.ModuleName, desc.Settings)
if err != nil {
return nil, err
}
@ -128,7 +128,7 @@ func (b Builder) Build(pName string, config map[string]interface{}, middlewareNa
return nil, fmt.Errorf("unknown plugin type: %s", pName)
}
func newMiddlewareBuilder(ctx context.Context, goPath string, manifest *Manifest, moduleName string) (middlewareBuilder, error) {
func newMiddlewareBuilder(ctx context.Context, goPath string, manifest *Manifest, moduleName string, settings Settings) (middlewareBuilder, error) {
switch manifest.Runtime {
case runtimeWasm:
wasmPath, err := getWasmPath(manifest)
@ -136,7 +136,7 @@ func newMiddlewareBuilder(ctx context.Context, goPath string, manifest *Manifest
return nil, fmt.Errorf("wasm path: %w", err)
}
return newWasmMiddlewareBuilder(goPath, moduleName, wasmPath), nil
return newWasmMiddlewareBuilder(goPath, moduleName, wasmPath, settings)
case runtimeYaegi, "":
i, err := newInterpreter(ctx, goPath, manifest.Import)