loop with range iterator
This showcases how to use the loopRange to generate a range list to be used as iterator for loop
Demo
source
Main task yaml file
tasks:
- name: task
task:
- func: cmd
desc: |
loopRange func will generate a range list named myloop
myloop will be registered as local var
the loop will use myloop to iterate through
dvars:
- name: void
value: '{{ loopRange 1 5 "myloop"}}'
do:
- name: print
cmd: '{{.loopitem}}'
loop: myloop
- func: cmd
desc: |
same as above, it will register a range list named my range
myrange list's name is then returned from the func call in loopRange, then
the name myrange will be used to refer to that var registered already
do:
- name: print
cmd: '{{.loopitem}}'
loop: '{{ loopRange 321 330 "myrange"}}'
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 -> c0168
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/c0168
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1: [
loopRange func will generate a range list named myloop
myloop will be registered as local var
the loop will use myloop to iterate through
]
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0,
"myloop": {
1,
2,
3,
4,
5
}
})
~SubStep1: [print: ]
1
~SubStep1: [print: ]
2
~SubStep1: [print: ]
3
~SubStep1: [print: ]
4
~SubStep1: [print: ]
5
-Step2: [
same as above, it will register a range list named my range
myrange list's name is then returned from the func call in loopRange, then
the name myrange will be used to refer to that var registered already
]
self: final context exec vars:
(*core.Cache)({
"myloop": {
1,
2,
3,
4,
5
},
"up_runtime_task_layer_number": 0
})
~SubStep1: [print: ]
321
~SubStep1: [print: ]
322
~SubStep1: [print: ]
323
~SubStep1: [print: ]
324
~SubStep1: [print: ]
325
~SubStep1: [print: ]
326
~SubStep1: [print: ]
327
~SubStep1: [print: ]
328
~SubStep1: [print: ]
329
~SubStep1: [print: ]
330
Logs with different verbose level
Raw logs with different verbose level