From 1a6d2be6d0a1590c2685edfdbbae76158f734de2 Mon Sep 17 00:00:00 2001 From: "Jian.Li" <74582607+leejanee@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:34:16 +0800 Subject: [PATCH] Feat(workflow): input.ParameterKey described like paths notation (#2214) * Feat(workflow): input.ParameterKey path notation * Feat(workflow): add test case * Fix(lint): format code --- pkg/workflow/tasks/custom/task.go | 2 +- pkg/workflow/tasks/custom/task_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/workflow/tasks/custom/task.go b/pkg/workflow/tasks/custom/task.go index 10da34a08..1820a80f2 100644 --- a/pkg/workflow/tasks/custom/task.go +++ b/pkg/workflow/tasks/custom/task.go @@ -109,7 +109,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (wfTypes.TaskGenerator, err if err != nil { return common.WorkflowStepStatus{}, nil, errors.WithMessagef(err, "get input from [%s]", input.From) } - if err := paramsValue.FillObject(inputValue, input.ParameterKey); err != nil { + if err := paramsValue.FillObject(inputValue, strings.Split(input.ParameterKey, ".")...); err != nil { return common.WorkflowStepStatus{}, nil, err } } diff --git a/pkg/workflow/tasks/custom/task_test.go b/pkg/workflow/tasks/custom/task_test.go index d00dc5b7e..c3faddecc 100644 --- a/pkg/workflow/tasks/custom/task_test.go +++ b/pkg/workflow/tasks/custom/task_test.go @@ -48,7 +48,7 @@ myIP: value: "1.1.1.1" return v.FillObject(ip) }, "input": func(ctx wfContext.Context, v *value.Value, act types.Action) error { - val, err := v.LookupValue("prefixIP") + val, err := v.LookupValue("set", "prefixIP") assert.NilError(t, err) str, err := val.CueValue().String() assert.NilError(t, err) @@ -87,7 +87,7 @@ myIP: value: "1.1.1.1" Type: "input", Inputs: v1beta1.StepInputs{{ From: "podIP", - ParameterKey: "prefixIP", + ParameterKey: "set.prefixIP", }}, }, {