github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0117.yml (about) 1 doc_meta: | 2 folder: loop 3 title: multi-layers loop 2 4 head: | 5 This showcases that you can use call func to achieve multiple layers of loop 6 7 sections: 8 - title: Demo 9 log: yes 10 11 notes: 12 goal: 13 - demo how to do double layered loop 14 - use call func to achieve that 15 16 tasks: 17 - 18 name: task 19 desc: main entry 20 task: 21 - 22 func: call 23 name: step2 24 desc: call subtask and exam the return value in following steps 25 do: subtask 26 loop: 27 - proc 1 28 - proc 2 29 - proc 3 30 31 - 32 name: subtask 33 desc: subtask to test reg and return 34 task: 35 36 - 37 func: cmd 38 name: step1 39 desc: the loopitem here is inherited from caller 40 do: 41 - name: print 42 cmd: '{{.loopitem}}' 43 44 # - 45 # func: cmd 46 # do: 47 # - name: exit 48 49 - 50 func: cmd 51 name: step2 52 desc: the loopitem here is the local defined loopitem 53 do: 54 - name: print 55 cmd: '{{.loopitem}}' 56 loop: 57 - item1 58 - item2 59 - item3 60 61 - 62 func: cmd 63 name: step3 64 desc: | 65 demo use both loopitem in same context 66 the dvar parentLoopItem will map the value of parent loopitem 67 dvars: 68 - name: parentLoopItem 69 value: '{{.loopitem}}' 70 do: 71 - name: print 72 cmd: 'parent loop: {{.parentLoopItem}}, child loop: {{.loopitem}}' 73 loop: 74 - item1 75 - item2 76 - item3