|
7 | 7 | "fmt" |
8 | 8 | "net/http" |
9 | 9 | "os" |
10 | | - "reflect" |
11 | 10 | "strconv" |
12 | 11 | "strings" |
13 | 12 | "sync" |
@@ -333,7 +332,7 @@ func NewResponseWriterWrapper(w http.ResponseWriter, statusCode int) *ResponseWr |
333 | 332 | } |
334 | 333 |
|
335 | 334 | func (ctx *FunctionContext) Send(outputName string, data []byte) ([]byte, error) { |
336 | | - if ctx.HasOutputs() { |
| 335 | + if !ctx.HasOutputs() { |
337 | 336 | return nil, errors.New("no output") |
338 | 337 | } |
339 | 338 |
|
@@ -384,19 +383,17 @@ func (ctx *FunctionContext) Send(outputName string, data []byte) ([]byte, error) |
384 | 383 | } |
385 | 384 |
|
386 | 385 | func (ctx *FunctionContext) HasInputs() bool { |
387 | | - nilInputs := map[string]*Input{} |
388 | | - if reflect.DeepEqual(ctx.Inputs, nilInputs) { |
389 | | - return false |
| 386 | + if len(ctx.GetInputs()) > 0 { |
| 387 | + return true |
390 | 388 | } |
391 | | - return true |
| 389 | + return false |
392 | 390 | } |
393 | 391 |
|
394 | 392 | func (ctx *FunctionContext) HasOutputs() bool { |
395 | | - nilOutputs := map[string]*Output{} |
396 | | - if reflect.DeepEqual(ctx.Outputs, nilOutputs) { |
397 | | - return false |
| 393 | + if len(ctx.GetOutputs()) > 0 { |
| 394 | + return true |
398 | 395 | } |
399 | | - return true |
| 396 | + return false |
400 | 397 | } |
401 | 398 |
|
402 | 399 | func (ctx *FunctionContext) ReturnOnSuccess() Out { |
@@ -694,17 +691,17 @@ func parseContext() (*FunctionContext, error) { |
694 | 691 | ctx.Event = &EventRequest{} |
695 | 692 | ctx.SyncRequest = &SyncRequest{} |
696 | 693 |
|
697 | | - if !ctx.HasInputs() { |
698 | | - for name, in := range ctx.Inputs { |
| 694 | + if ctx.HasInputs() { |
| 695 | + for name, in := range ctx.GetInputs() { |
699 | 696 | if _, err := getBuildingBlockType(in.ComponentType); err != nil { |
700 | 697 | klog.Errorf("failed to get building block type for input %s: %v", name, err) |
701 | 698 | return nil, err |
702 | 699 | } |
703 | 700 | } |
704 | 701 | } |
705 | 702 |
|
706 | | - if !ctx.HasOutputs() { |
707 | | - for name, out := range ctx.Outputs { |
| 703 | + if ctx.HasOutputs() { |
| 704 | + for name, out := range ctx.GetOutputs() { |
708 | 705 | if _, err := getBuildingBlockType(out.ComponentType); err != nil { |
709 | 706 | klog.Errorf("failed to get building block type for output %s: %v", name, err) |
710 | 707 | return nil, err |
|
0 commit comments