From c10de438c337ab1854eaa74836be0b69941f0744 Mon Sep 17 00:00:00 2001 From: Kevin Mingtarja Date: Tue, 29 Apr 2025 11:35:49 -0700 Subject: [PATCH 1/2] Add support for passing in environment variables to the WASM module --- runtime/wasmhost/wasmhost.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/runtime/wasmhost/wasmhost.go b/runtime/wasmhost/wasmhost.go index 55e8ca78d..e2ed6f2d0 100644 --- a/runtime/wasmhost/wasmhost.go +++ b/runtime/wasmhost/wasmhost.go @@ -14,6 +14,8 @@ import ( "crypto/rand" "fmt" "io" + "os" + "strings" "github.com/hypermodeinc/modus/runtime/functions" "github.com/hypermodeinc/modus/runtime/logger" @@ -135,6 +137,15 @@ func (host *wasmHost) GetModuleInstance(ctx context.Context, plugin *plugins.Plu WithEnv("TZ", timeZone). WithEnv("CLAIMS", jwtClaims) + for _, env := range os.Environ() { + split := strings.SplitN(env, "=", 2) + key, val := split[0], split[1] + if strings.HasPrefix(key, "MODUS_") { + // Remove the MODUS_ prefix + cfg = cfg.WithEnv(key[6:], val) + } + } + // Instantiate the plugin as a module. // NOTE: This will also invoke the plugin's `_start` function, // which will call any top-level code in the plugin. From 90bf0fd7f29e115a6768a6c94b7a188903ce4325 Mon Sep 17 00:00:00 2001 From: Kevin Mingtarja Date: Tue, 29 Apr 2025 11:45:29 -0700 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd3637219..2bceceb4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ # Change Log +## 2025-04-29 - Runtime 0.17.11 + +- feat: Add support for passing in environment variables to the WASM module [#831](https://github.com/hypermodeinc/modus/pull/831) + ## 2025-04-18 - Runtime 0.17.10 - fix: return immediately after encountering JWT parse error [#826](https://github.com/hypermodeinc/modus/pull/826)