loopitem in callee's dvar
This showcases the loopitem/loopindex will be available in the dvars scope for reference
Demo
source
Main task yaml file
tasks:
- name: task
task:
- func: call
do:
- subtask1
loop:
- tom
- jerry
- emily
- name: subtask1
task:
- func: cmd
do:
- name: print
cmd: '{{.loopindex1}}:{{.loopitem}}'
- func: cmd
do:
- name: assert
cmd:
- '{{eq .loopitem "tom"}}'
if: '{{eq .loopindex1 1}}'
- func: cmd
vars:
person: '{{.loopitem}}'
do:
- name: print
cmd: '{{.person}}'
- func: cmd
dvars:
- name: theone
value: '{{.loopitem}}'
do:
- name: print
cmd: '{{.theone}}'
Main log file
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0110
Verbose -> vvv
ModuleName -> self
ShellType -> /bin/sh
MaxCallLayers -> 8
Timeout -> 3600000
MaxModuelCallLayers -> 256
EntryTask -> task
ModRepoUsernameRef ->
ModRepoPasswordRef ->
work dir: /up_project/up
-exec task: task
loading [Task]: ./tests/functests/c0110
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0
})
=Task2: [task ==> subtask1: ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"loopindex": 0,
"loopindex1": 1,
"up_runtime_task_layer_number": 1,
"loopitem": "tom"
})
~~SubStep1: [print: ]
1:tom
--Step2:
self: final context exec vars:
(*core.Cache)({
"loopindex": 0,
"loopindex1": 1,
"up_runtime_task_layer_number": 1,
"loopitem": "tom"
})
~~SubStep1: [assert: ]
1 ASSERT OK: [{{eq .loopitem "tom"}}]
--Step3:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"loopitem": "tom",
"loopindex": 0,
"loopindex1": 1,
"person": "{{.loopitem}}"
})
~~SubStep1: [print: ]
{{.loopitem}}
--Step4:
self: final context exec vars:
(*core.Cache)({
"loopitem": "tom",
"loopindex": 0,
"loopindex1": 1,
"up_runtime_task_layer_number": 1,
"theone": "tom"
})
~~SubStep1: [print: ]
tom
=Task2: [task ==> subtask1: ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"loopitem": "jerry",
"loopindex": 1,
"loopindex1": 2,
"up_runtime_task_layer_number": 1
})
~~SubStep1: [print: ]
2:jerry
--Step2:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"loopitem": "jerry",
"loopindex": 1,
"loopindex1": 2
})
condition failed, skip executing step
--Step3:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"person": "{{.loopitem}}",
"loopitem": "jerry",
"loopindex": 1,
"loopindex1": 2
})
~~SubStep1: [print: ]
{{.loopitem}}
--Step4:
self: final context exec vars:
(*core.Cache)({
"loopitem": "jerry",
"loopindex": 1,
"theone": "jerry",
"loopindex1": 2,
"up_runtime_task_layer_number": 1
})
~~SubStep1: [print: ]
jerry
=Task2: [task ==> subtask1: ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"loopitem": "emily",
"loopindex": 2,
"loopindex1": 3,
"up_runtime_task_layer_number": 1
})
~~SubStep1: [print: ]
3:emily
--Step2:
self: final context exec vars:
(*core.Cache)({
"loopindex1": 3,
"up_runtime_task_layer_number": 1,
"loopitem": "emily",
"loopindex": 2
})
condition failed, skip executing step
--Step3:
self: final context exec vars:
(*core.Cache)({
"loopindex": 2,
"loopindex1": 3,
"person": "{{.loopitem}}",
"up_runtime_task_layer_number": 1,
"loopitem": "emily"
})
~~SubStep1: [print: ]
{{.loopitem}}
--Step4:
self: final context exec vars:
(*core.Cache)({
"loopindex1": 3,
"up_runtime_task_layer_number": 1,
"loopitem": "emily",
"loopindex": 2,
"theone": "emily"
})
~~SubStep1: [print: ]
emily
Logs with different verbose level
Raw logs with different verbose level