Skip to content

Commit

Permalink
Fix: input error stores structure type data (#91)
Browse files Browse the repository at this point in the history
Signed-off-by: songyang.song <songyang.song@alibaba-inc.com>

Signed-off-by: songyang.song <songyang.song@alibaba-inc.com>
Co-authored-by: songyang.song <songyang.song@alibaba-inc.com>
  • Loading branch information
yangsoon and songyang.song committed Nov 29, 2022
1 parent 3f1eab6 commit de4facb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/tasks/custom/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func getInputsTemplate(ctx wfContext.Context, step v1alpha1.WorkflowStep, basicV
if err != nil {
continue
}
inputsTempl += fmt.Sprintf("\ninputs: \"%s\": %s", input.From, s)
inputsTempl += fmt.Sprintf("\ninputs: \"%s\": {\n%s\n}", input.From, s)
}
return inputsTempl
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/tasks/custom/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,20 @@ func TestValidateIfValue(t *testing.T) {
expectedErr: "not found",
expected: false,
},
{
name: "input value is struct",
step: v1alpha1.WorkflowStep{
WorkflowStepBase: v1alpha1.WorkflowStepBase{
If: `inputs["test-struct"].hello == "world"`,
Inputs: v1alpha1.StepInputs{
{
From: "test-struct",
},
},
},
},
expected: true,
},
{
name: "dash in if",
step: v1alpha1.WorkflowStep{
Expand Down Expand Up @@ -782,6 +796,9 @@ func newWorkflowContextForTest(t *testing.T) wfContext.Context {
v, err = value.NewValue(`"yes"`, nil, "")
r.NoError(err)
r.NoError(wfCtx.SetVar(v, "test"))
v, err = value.NewValue(`{hello: "world"}`, nil, "")
r.NoError(err)
r.NoError(wfCtx.SetVar(v, "test-struct"))
return wfCtx
}

Expand Down

0 comments on commit de4facb

Please sign in to comment.