From 6b892f0877a2bd98826cfdb899dd795bdc4be382 Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 21 Jul 2024 23:07:53 +0200 Subject: [PATCH] Plugins: allow outpurs to copy from input (#14960) --- provider/go.go | 9 +++++++++ provider/javascript.go | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/provider/go.go b/provider/go.go index d9e4610ac9..7cf096e14d 100644 --- a/provider/go.go +++ b/provider/go.go @@ -1,6 +1,7 @@ package provider import ( + "errors" "fmt" "reflect" @@ -144,6 +145,10 @@ func (p *Go) handleGetter() (any, error) { } func (p *Go) handleSetter(param string, val any) error { + if err := transformInputs(p.in, p.setParam); err != nil { + return err + } + if err := p.setParam(param, val); err != nil { return err } @@ -168,6 +173,10 @@ func (p *Go) evaluate() (res any, err error) { return nil, err } + if !v.IsValid() { + return nil, errors.New("missing result") + } + if (v.Kind() == reflect.Pointer || v.Kind() == reflect.Interface) && v.IsNil() { return nil, nil } diff --git a/provider/javascript.go b/provider/javascript.go index ca87eb4e4f..67f0338d15 100644 --- a/provider/javascript.go +++ b/provider/javascript.go @@ -125,6 +125,10 @@ func (p *Javascript) handleGetter() (any, error) { } func (p *Javascript) handleSetter(param string, val any) error { + if err := transformInputs(p.in, p.setParamSync); err != nil { + return err + } + javascript.Lock() if err := p.setParam(param, val); err != nil { javascript.Unlock()