Standardize action results

This commit is contained in:
mudler
2025-03-01 17:27:07 +01:00
parent 8492c95cb6
commit 5b4f618ca3
22 changed files with 108 additions and 67 deletions

View File

@@ -75,15 +75,16 @@ func (a *CustomAction) initializeInterpreter() error {
return nil
}
func (a *CustomAction) Run(ctx context.Context, params ActionParams) (string, error) {
func (a *CustomAction) Run(ctx context.Context, params ActionParams) (ActionResult, error) {
v, err := a.i.Eval(fmt.Sprintf("%s.Run", a.config["name"]))
if err != nil {
return "", err
return ActionResult{}, err
}
run := v.Interface().(func(map[string]interface{}) (string, error))
run := v.Interface().(func(map[string]interface{}) (string, map[string]interface{}, error))
return run(params)
res, meta, err := run(params)
return ActionResult{Result: res, Metadata: meta}, err
}
func (a *CustomAction) Definition() ActionDefinition {