mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-01-31 10:23:28 +01:00
feat: provide app url (#1087)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user