From 8c977b8f8cb43396c21bd38c96e01fc5c617907b Mon Sep 17 00:00:00 2001 From: Julien Salleyron Date: Mon, 16 Sep 2024 11:12:04 +0200 Subject: [PATCH] Removes goexport dependency and adds _initialize --- go.mod | 2 +- go.sum | 2 -- pkg/plugins/middlewarewasm.go | 5 ++--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 545e61b52..b7ae066bf 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,6 @@ require ( github.com/http-wasm/http-wasm-host-go v0.6.0 github.com/influxdata/influxdb-client-go/v2 v2.7.0 github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab // No tag on the repo. - github.com/juliens/wasm-goexport v0.0.6 github.com/klauspost/compress v1.17.9 github.com/kvtools/consul v1.0.2 github.com/kvtools/etcdv3 v1.0.2 @@ -371,4 +370,5 @@ replace ( // tencentcloud uses monorepo with multimodule but the go.mod files are incomplete. exclude github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible +// Replace to handle new wasmexport in official go and wazergo for http calls. replace github.com/http-wasm/http-wasm-host-go => github.com/traefik/http-wasm-host-go v0.0.0-20240618100324-3c53dcaa1a70 diff --git a/go.sum b/go.sum index 927bfbf39..63b785fcf 100644 --- a/go.sum +++ b/go.sum @@ -590,8 +590,6 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/juliens/wasm-goexport v0.0.6 h1:YU0c+j0dF/HNy32vgYTA+K/6wnsZXgGc+ihl/UDw8iA= -github.com/juliens/wasm-goexport v0.0.6/go.mod h1:VTTpJVY3tIBet0Gv8r5TxdsNg0vDkkqXYm0Hp5hR42A= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 h1:qGQQKEcAR99REcMpsXCp3lJ03zYT1PkRd3kQGPn9GVg= diff --git a/pkg/plugins/middlewarewasm.go b/pkg/plugins/middlewarewasm.go index a9f4f5ada..f8dc7d1bf 100644 --- a/pkg/plugins/middlewarewasm.go +++ b/pkg/plugins/middlewarewasm.go @@ -12,7 +12,6 @@ import ( "github.com/http-wasm/http-wasm-host-go/handler" wasm "github.com/http-wasm/http-wasm-host-go/handler/nethttp" - "github.com/juliens/wasm-goexport/host" "github.com/tetratelabs/wazero" "github.com/traefik/traefik/v3/pkg/logs" "github.com/traefik/traefik/v3/pkg/middlewares" @@ -67,7 +66,7 @@ func (b *wasmMiddlewareBuilder) buildMiddleware(ctx context.Context, next http.H return nil, nil, fmt.Errorf("loading binary: %w", err) } - rt := host.NewRuntime(wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfig().WithCompilationCache(b.cache))) + rt := wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfig().WithCompilationCache(b.cache)) guestModule, err := rt.CompileModule(ctx, code) if err != nil { @@ -81,7 +80,7 @@ func (b *wasmMiddlewareBuilder) buildMiddleware(ctx context.Context, next http.H logger := middlewares.GetLogger(ctx, middlewareName, "wasm") - config := wazero.NewModuleConfig().WithSysWalltime() + config := wazero.NewModuleConfig().WithSysWalltime().WithStartFunctions("_start", "_initialize") for _, env := range b.settings.Envs { config.WithEnv(env, os.Getenv(env)) }