multi-layers loop 2

This showcases that you can use call func to achieve multiple layers of loop

Demo

source

Main task yaml file
    tasks:
    - name: task
      desc: main entry
      task:
      - func: call
        name: step2
        desc: call subtask and exam the return value in following steps
        do: subtask
        loop:
        - proc 1
        - proc 2
        - proc 3
    - name: subtask
      desc: subtask to test reg and return
      task:
      - func: cmd
        name: step1
        desc: the loopitem here is inherited from caller
        do:
        - name: print
          cmd: '{{.loopitem}}'
          #      -
          #        func: cmd
          #        do:
          #          - name: exit
      - func: cmd
        name: step2
        desc: the loopitem here is the local defined loopitem
        do:
        - name: print
          cmd: '{{.loopitem}}'
        loop:
        - item1
        - item2
        - item3
      - func: cmd
        name: step3
        desc: |
          demo use both loopitem in same context
          the dvar parentLoopItem will map the value of parent loopitem
        dvars:
        - name: parentLoopItem
          value: '{{.loopitem}}'
        do:
        - name: print
          cmd: 'parent loop: {{.parentLoopItem}}, child loop: {{.loopitem}}'
        loop:
        - item1
        - item2
        - item3
    
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 -> c0117
                 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/c0117
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task: main entry ]
    -Step1: [step2: call subtask and exam the return value in following steps ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 0
    })
    
    =Task2: [task ==> subtask: subtask to test reg and return ]
    --Step1: [step1: the loopitem here is inherited from caller ]
    self: final context exec vars:
    
    (*core.Cache)({
      "loopitem": "proc 1",
      "loopindex": 0,
      "loopindex1": 1,
      "up_runtime_task_layer_number": 1
    })
    
    ~~SubStep1: [print:  ]
    proc 1
    --Step2: [step2: the loopitem here is the local defined loopitem ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1,
      "loopitem": "proc 1",
      "loopindex": 0,
      "loopindex1": 1
    })
    
    ~~SubStep1: [print:  ]
    item1
    ~~SubStep1: [print:  ]
    item2
    ~~SubStep1: [print:  ]
    item3
    --Step3: [
    step3demo use both loopitem in same context
    the dvar parentLoopItem will map the value of parent loopitem
    ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1,
      "loopitem": "proc 1",
      "loopindex": 0,
      "loopindex1": 1,
      "parentLoopItem": "proc 1"
    })
    
    ~~SubStep1: [print:  ]
    parent loop: proc 1, child loop: item1
    ~~SubStep1: [print:  ]
    parent loop: proc 1, child loop: item2
    ~~SubStep1: [print:  ]
    parent loop: proc 1, child loop: item3
    =Task2: [task ==> subtask: subtask to test reg and return ]
    --Step1: [step1: the loopitem here is inherited from caller ]
    self: final context exec vars:
    
    (*core.Cache)({
      "loopindex1": 2,
      "up_runtime_task_layer_number": 1,
      "loopitem": "proc 2",
      "loopindex": 1
    })
    
    ~~SubStep1: [print:  ]
    proc 2
    --Step2: [step2: the loopitem here is the local defined loopitem ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1,
      "loopitem": "proc 2",
      "loopindex": 1,
      "loopindex1": 2
    })
    
    ~~SubStep1: [print:  ]
    item1
    ~~SubStep1: [print:  ]
    item2
    ~~SubStep1: [print:  ]
    item3
    --Step3: [
    step3demo use both loopitem in same context
    the dvar parentLoopItem will map the value of parent loopitem
    ]
    self: final context exec vars:
    
    (*core.Cache)({
      "parentLoopItem": "proc 2",
      "loopindex1": 2,
      "up_runtime_task_layer_number": 1,
      "loopitem": "proc 2",
      "loopindex": 1
    })
    
    ~~SubStep1: [print:  ]
    parent loop: proc 2, child loop: item1
    ~~SubStep1: [print:  ]
    parent loop: proc 2, child loop: item2
    ~~SubStep1: [print:  ]
    parent loop: proc 2, child loop: item3
    =Task2: [task ==> subtask: subtask to test reg and return ]
    --Step1: [step1: the loopitem here is inherited from caller ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1,
      "loopitem": "proc 3",
      "loopindex": 2,
      "loopindex1": 3
    })
    
    ~~SubStep1: [print:  ]
    proc 3
    --Step2: [step2: the loopitem here is the local defined loopitem ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1,
      "loopitem": "proc 3",
      "loopindex": 2,
      "loopindex1": 3
    })
    
    ~~SubStep1: [print:  ]
    item1
    ~~SubStep1: [print:  ]
    item2
    ~~SubStep1: [print:  ]
    item3
    --Step3: [
    step3demo use both loopitem in same context
    the dvar parentLoopItem will map the value of parent loopitem
    ]
    self: final context exec vars:
    
    (*core.Cache)({
      "loopindex1": 3,
      "up_runtime_task_layer_number": 1,
      "loopitem": "proc 3",
      "loopindex": 2,
      "parentLoopItem": "proc 3"
    })
    
    ~~SubStep1: [print:  ]
    parent loop: proc 3, child loop: item1
    ~~SubStep1: [print:  ]
    parent loop: proc 3, child loop: item2
    ~~SubStep1: [print:  ]
    parent loop: proc 3, child loop: item3
    
Logs with different verbose level
Raw logs with different verbose level