Skip to content

Commit cba80c6

Browse files
committed
add tsunami:env meta
1 parent 4dbd00e commit cba80c6

4 files changed

Lines changed: 19 additions & 8 deletions

File tree

frontend/types/gotypes.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ declare global {
595595
"tsunami:sdkreplacepath"?: string;
596596
"tsunami:apppath"?: string;
597597
"tsunami:scaffoldpath"?: string;
598+
"tsunami:env"?: {[key: string]: string};
598599
"vdom:*"?: boolean;
599600
"vdom:initialized"?: boolean;
600601
"vdom:correlationid"?: string;

pkg/blockcontroller/tsunamicontroller.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (c *TsunamiController) Start(ctx context.Context, blockMeta waveobj.MetaMap
217217
return fmt.Errorf("app cache is not executable: %s", cachePath)
218218
}
219219

220-
tsunamiProc, err := runTsunamiAppBinary(ctx, cachePath, appPath)
220+
tsunamiProc, err := runTsunamiAppBinary(ctx, cachePath, appPath, blockMeta)
221221
if err != nil {
222222
return fmt.Errorf("failed to run tsunami app: %w", err)
223223
}
@@ -300,10 +300,18 @@ func (c *TsunamiController) SendInput(input *BlockInputUnion) error {
300300
return fmt.Errorf("tsunami controller send input not implemented")
301301
}
302302

303-
func runTsunamiAppBinary(ctx context.Context, appBinPath string, appPath string) (*TsunamiAppProc, error) {
303+
func runTsunamiAppBinary(ctx context.Context, appBinPath string, appPath string, blockMeta waveobj.MetaMapType) (*TsunamiAppProc, error) {
304304
cmd := exec.Command(appBinPath)
305305
cmd.Env = append(os.Environ(), "TSUNAMI_CLOSEONSTDIN=1")
306306

307+
// Add TsunamiEnv variables if configured
308+
tsunamiEnv := blockMeta.GetMap(waveobj.MetaKey_TsunamiEnv)
309+
for key, value := range tsunamiEnv {
310+
if strValue, ok := value.(string); ok {
311+
cmd.Env = append(cmd.Env, key+"="+strValue)
312+
}
313+
}
314+
307315
stdoutPipe, err := cmd.StdoutPipe()
308316
if err != nil {
309317
return nil, fmt.Errorf("failed to create stdout pipe: %w", err)
@@ -320,12 +328,12 @@ func runTsunamiAppBinary(ctx context.Context, appBinPath string, appPath string)
320328
}
321329

322330
appName := build.GetAppName(appPath)
323-
331+
324332
stdoutBuffer := utilds.MakeReaderLineBuffer(stdoutPipe, 1000)
325333
stdoutBuffer.SetLineCallback(func(line string) {
326334
log.Printf("[tsunami:%s] %s\n", appName, line)
327335
})
328-
336+
329337
stderrBuffer := utilds.MakeReaderLineBuffer(stderrPipe, 1000)
330338
stderrBuffer.SetLineCallback(func(line string) {
331339
log.Printf("[tsunami:%s] %s\n", appName, line)

pkg/waveobj/metaconsts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const (
118118
MetaKey_TsunamiSdkReplacePath = "tsunami:sdkreplacepath"
119119
MetaKey_TsunamiAppPath = "tsunami:apppath"
120120
MetaKey_TsunamiScaffoldPath = "tsunami:scaffoldpath"
121+
MetaKey_TsunamiEnv = "tsunami:env"
121122

122123
MetaKey_VDomClear = "vdom:*"
123124
MetaKey_VDomInitialized = "vdom:initialized"

pkg/waveobj/wtypemeta.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ type MetaTSType struct {
117117
MarkdownFontSize float64 `json:"markdown:fontsize,omitempty"`
118118
MarkdownFixedFontSize float64 `json:"markdown:fixedfontsize,omitempty"`
119119

120-
TsunamiClear bool `json:"tsunami:*,omitempty"`
121-
TsunamiSdkReplacePath string `json:"tsunami:sdkreplacepath,omitempty"`
122-
TsunamiAppPath string `json:"tsunami:apppath,omitempty"`
123-
TsunamiScaffoldPath string `json:"tsunami:scaffoldpath,omitempty"`
120+
TsunamiClear bool `json:"tsunami:*,omitempty"`
121+
TsunamiSdkReplacePath string `json:"tsunami:sdkreplacepath,omitempty"`
122+
TsunamiAppPath string `json:"tsunami:apppath,omitempty"`
123+
TsunamiScaffoldPath string `json:"tsunami:scaffoldpath,omitempty"`
124+
TsunamiEnv map[string]string `json:"tsunami:env,omitempty"`
124125

125126
VDomClear bool `json:"vdom:*,omitempty"`
126127
VDomInitialized bool `json:"vdom:initialized,omitempty"`

0 commit comments

Comments
 (0)