feat: provide app url (#1087)

This commit is contained in:
Jonas Plum
2024-07-21 09:24:06 +02:00
committed by GitHub
parent 83251af565
commit 4db718660a
5 changed files with 38 additions and 11 deletions

View File

@@ -28,7 +28,10 @@ func Run(ctx context.Context, app core.App, actionName, actionData, payload stri
return nil, fmt.Errorf("failed to get system token: %w", err)
}
a.SetToken(token)
a.SetEnv([]string{
"CATALYST_APP_URL=" + app.Settings().Meta.AppUrl,
"CATALYST_TOKEN=" + token,
})
}
return action.Run(ctx, payload)
@@ -39,7 +42,7 @@ type action interface {
}
type authenticatedAction interface {
SetToken(token string)
SetEnv(env []string)
}
func decode(actionName, actionData string) (action, error) {

View File

@@ -13,11 +13,11 @@ type Python struct {
Requirements string `json:"requirements"`
Script string `json:"script"`
token string
env []string
}
func (a *Python) SetToken(token string) {
a.token = token
func (a *Python) SetEnv(env []string) {
a.env = env
}
func (a *Python) Run(ctx context.Context, payload string) ([]byte, error) {
@@ -101,10 +101,7 @@ func (a *Python) pythonRunScript(ctx context.Context, tempDir, payload string) (
cmd := exec.CommandContext(ctx, pythonPath, scriptPath, payload)
cmd.Env = []string{}
if a.token != "" {
cmd.Env = append(cmd.Env, "CATALYST_TOKEN="+a.token)
}
cmd.Env = a.env
return cmd.Output()
}