tasks:
- name: task
task:
- func: cmd
name: wrong_usage
desc: |
note that you can't access loopitem in dvar processing in curent func
you can only access loopitem in dvar processing when it is called as callee, as corret_usage shows
however you can access loopitem in do action
dvars:
- name: person
value: '{{.loopitem}}'
flags:
- v
loop:
- tom
- peter
- james
do:
- name: print
cmd: |
loopitme could be accessed here: {{.loopitem}}
- func: call
name: corret_usage
vars:
taskvar: taskvar
do:
- task_callee2
loop:
- tom
- peter
- james
- name: task_callee1
task:
- func: cmd
do:
- name: print
cmd: 'hello {{.loopitem}}'
- name: task_callee2
task:
- func: cmd
dvars:
- name: person
value: '{{.loopitem}}'
flags: [v]
do:
- name: print
desc: as explained, this should be <no value>
cmd: 'callee2: {{.person}}'
- name: print
desc: |
this will be the loopitem from parent caller's
var space and this is design
cmd: 'callee2: {{.loopitem}}'
- name: print
cmd: 'callee2: {{.greet}}'
- name: print
cmd: 'taskvar: {{.taskvar}}'
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0090
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/c0090
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1: [
wrong_usagenote that you can't access loopitem in dvar processing in curent func
you can only access loopitem in dvar processing when it is called as callee, as corret_usage shows
however you can access loopitem in do action
]
dvar> person:
"None"
-
None
self: final context exec vars:
(*core.Cache)({
"person": "None",
"up_runtime_task_layer_number": 0
})
~SubStep1: [print: ]
loopitme could be accessed here: tom
~SubStep1: [print: ]
loopitme could be accessed here: peter
~SubStep1: [print: ]
loopitme could be accessed here: james
-Step2: [corret_usage: ]
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0,
"taskvar": "taskvar"
})
=Task3: [task ==> task_callee2: ]
--Step1:
dvar> person:
"tom"
-
tom
self: final context exec vars:
(*core.Cache)({
"loopindex": 0,
"loopindex1": 1,
"person": "tom",
"up_runtime_task_layer_number": 1,
"taskvar": "taskvar",
"loopitem": "tom"
})
~~SubStep1: [print: as explained, this should be <no value> ]
callee2: tom
~~SubStep2: [print: this will be the loopitem from parent caller's
var space and this is design
]
callee2: tom
~~SubStep3: [print: ]
callee2: <no value>
~~SubStep4: [print: ]
taskvar: taskvar
=Task3: [task ==> task_callee2: ]
--Step1:
dvar> person:
"peter"
-
peter
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"person": "peter",
"taskvar": "taskvar",
"loopitem": "peter",
"loopindex": 1,
"loopindex1": 2
})
~~SubStep1: [print: as explained, this should be <no value> ]
callee2: peter
~~SubStep2: [print: this will be the loopitem from parent caller's
var space and this is design
]
callee2: peter
~~SubStep3: [print: ]
callee2: <no value>
~~SubStep4: [print: ]
taskvar: taskvar
=Task3: [task ==> task_callee2: ]
--Step1:
dvar> person:
"james"
-
james
self: final context exec vars:
(*core.Cache)({
"loopindex1": 3,
"up_runtime_task_layer_number": 1,
"taskvar": "taskvar",
"loopitem": "james",
"person": "james",
"loopindex": 2
})
~~SubStep1: [print: as explained, this should be <no value> ]
callee2: james
~~SubStep2: [print: this will be the loopitem from parent caller's
var space and this is design
]
callee2: james
~~SubStep3: [print: ]
callee2: <no value>
~~SubStep4: [print: ]
taskvar: taskvar
As self explained in the wrong_usage desc, you can’t access loopitem in dvars in current stack. There are two ways you will have to access loopitem in dvar processing: 1. shown as correct_usage, use call to delegate loop process to a callee task 2. use block func, so the dvar in any func in actually in the callee stack