NewFunctionCall builds a FunctionCall. Validates that every declared return has a matching output binding.
(id string, fn *engine.Function, inputBindings map[string]workflow.Expression, outputBindings map[string]workflow.OutputBinding, toolDescription string)
| 38 | // has a matching output binding. |
| 39 | func NewFunctionCall(id string, fn *engine.Function, inputBindings map[string]workflowapi.Expression, outputBindings map[string]workflowapi.OutputBinding, toolDescription string) (*FunctionCall, error) { |
| 40 | for _, ret := range fn.Info.Returns { |
| 41 | if _, ok := outputBindings[ret.Uid]; !ok { |
| 42 | return nil, fmt.Errorf("function_call %s: missing output binding for return %s (uid %s)", id, ret.Name, ret.Uid) |
| 43 | } |
| 44 | } |
| 45 | for _, arg := range fn.Info.Arguments { |
| 46 | if _, ok := inputBindings[arg.Uid]; !ok { |
| 47 | return nil, fmt.Errorf("function_call %s: missing input binding for argument %s (uid %s)", id, arg.Name, arg.Uid) |
| 48 | } |
| 49 | } |
| 50 | return &FunctionCall{ |
| 51 | LinearNode: engine.NewLinearNode(id), |
| 52 | fn: fn, |
| 53 | inputBindings: inputBindings, |
| 54 | outputBindings: outputBindings, |
| 55 | toolDescription: toolDescription, |
| 56 | }, nil |
| 57 | } |
| 58 | |
| 59 | func (n *FunctionCall) Outputs() map[string]workflowapi.DataType { |
| 60 | raw := make(map[string]workflowapi.DataType, len(n.fn.Info.Returns)) |
| 61 | for _, ret := range n.fn.Info.Returns { |
no outgoing calls