Append custom args when executing corredor scripts via Compose REST handlers

This commit is contained in:
Denis Arh
2022-02-25 15:13:14 +01:00
parent f5c4f76c04
commit 0f6e712487
4 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ package rest
import (
"context"
"github.com/cortezaproject/corteza-server/pkg/api"
"github.com/cortezaproject/corteza-server/compose/rest/request"
@@ -47,5 +48,5 @@ func (ctrl *Automation) Bundle(ctx context.Context, r *request.AutomationBundle)
}
func (ctrl *Automation) TriggerScript(ctx context.Context, r *request.AutomationTriggerScript) (interface{}, error) {
return api.OK(), corredor.Service().Exec(ctx, r.Script, event.ComposeOnManual())
return api.OK(), corredor.Service().Exec(ctx, r.Script, corredor.ExtendScriptArgs(event.ComposeOnManual(), r.Args))
}
+1 -1
View File
@@ -162,7 +162,7 @@ func (ctrl *Module) TriggerScript(ctx context.Context, r *request.ModuleTriggerS
}
// @todo implement same behaviour as we have on record - module+oldModule
err = corredor.Service().Exec(ctx, r.Script, event.ModuleOnManual(module, module, namespace))
err = corredor.Service().Exec(ctx, r.Script, corredor.ExtendScriptArgs(event.ModuleOnManual(module, module, namespace), r.Args))
return ctrl.makePayload(ctx, module, err)
}
+1 -1
View File
@@ -318,7 +318,7 @@ func (ctrl *Namespace) TriggerScript(ctx context.Context, r *request.NamespaceTr
return
}
err = corredor.Service().Exec(ctx, r.Script, event.NamespaceOnManual(namespace, nil))
err = corredor.Service().Exec(ctx, r.Script, corredor.ExtendScriptArgs(event.NamespaceOnManual(namespace, nil), r.Args))
return ctrl.makePayload(ctx, namespace, err)
}
+1 -1
View File
@@ -234,7 +234,7 @@ func (ctrl *Page) TriggerScript(ctx context.Context, r *request.PageTriggerScrip
}
// @todo implement same behaviour as we have on record - page+oldPage
err = corredor.Service().Exec(ctx, r.Script, event.PageOnManual(page, page, namespace, nil))
err = corredor.Service().Exec(ctx, r.Script, corredor.ExtendScriptArgs(event.PageOnManual(page, page, namespace, nil), r.Args))
return ctrl.makePayload(ctx, page, err)
}