Skip to content

Commit

Permalink
Plugins: allow outpurs to copy from input (#14960)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Jul 21, 2024
1 parent dbd4c4f commit 6b892f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions provider/go.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package provider

import (
"errors"
"fmt"
"reflect"

Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions provider/javascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6b892f0

Please sign in to comment.