loop with condition

This showcases the conditional loop

Demo

source

Main task yaml file
    vars:
      items:
      - item1
      - item2
      - item3
      loopkey: items
    tasks:
    - name: task
      desc: main entry
      task:
      - func: cmd
        vars:
          person: tom
        name: step1
        desc: demo loop will not be executed if false
        do:
        - name: print
          cmd: '{{.loopitem}}'
        loop:
        - item1
        - item2
        - item3
        if: '{{eq .person "tom hanks"}}'
      - func: cmd
        vars:
          person: tom
        name: step1
        desc: demo use if condition is true
        do:
        - name: print
          cmd: '{{.loopitem}}'
        loop:
        - item1
        - item2
        - item3
        if: '{{eq .person "tom  "}}'
      - func: cmd
        name: step1
        desc: demo use dynamic key to ref to a loop item from var
        do:
        - name: print
          cmd: '{{.loopitem}}'
        loop: '{{.loopkey}}'
    
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 -> c0118
                 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/c0118
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task: main entry ]
    -Step1: [step1: demo loop will not be executed if false ]
    self: final context exec vars:
    
    (*core.Cache)({
      "items": {
        "item1",
        "item2",
        "item3"
      },
      "loopkey": "items",
      "up_runtime_task_layer_number": 0,
      "person": "tom"
    })
    
    condition failed, skip executing step step1
    
    -Step2: [step1: demo use if condition is true ]
    self: final context exec vars:
    
    (*core.Cache)({
      "items": {
        "item1",
        "item2",
        "item3"
      },
      "loopkey": "items",
      "up_runtime_task_layer_number": 0,
      "person": "tom"
    })
    
    condition failed, skip executing step step1
    
    -Step3: [step1: demo use dynamic key to ref to a loop item from var ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 0,
      "items": {
        "item1",
        "item2",
        "item3"
      },
      "loopkey": "items"
    })
    
    ~SubStep1: [print:  ]
    item1
    ~SubStep1: [print:  ]
    item2
    ~SubStep1: [print:  ]
    item3
    
Logs with different verbose level
Raw logs with different verbose level