use block

Block func is introduced for an alternative coding style to mainly deal with internal business. Call func mainly serves to offer interoperability and sharing and exchanging code with different projects/teams, block func in the oposite, it allows your code to share the same vars stack as long as your func is in one of the leave level in tree of a block

Vars inherit from block func vars and auto merge

Please notice that the values printed out in print cmd in the flow of steps in block func, the vars: a, b, da, db will inherit the values defined in vars in block func

Demo

source

Main task yaml file
    vars:
      a: global_aaa
      b: global_bbb
      c: global_ccc
    tasks:
    - name: task
      task:
      - func: block
        desc: show example the route goes to call goelse for the condition of not if condition
          succeeds
        vars:
          a: local_aaa
          b: local_bbb
        dvars:
        - name: da
          value: local_da
        - name: db
          value: local_db
        do:
        - func: shell
          do:
          - echo "shell step1"
          - echo "shell step2"
        - func: cmd
          do:
          - name: print
            cmd: |
              cmd print step
              up_runtime_task_layer_number: {{.up_runtime_task_layer_number}}
              a: {{.a}}
              b: {{.b}}
              da: {{.da}}
              db: {{.db}}
    
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 -> c0128
                 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/c0128
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1: [: show example the route goes to call goelse for the condition of not if condition succeeds ]
    self: final context exec vars:
    
    (*core.Cache)({
      "a": "local_aaa",
      "b": "local_bbb",
      "c": "global_ccc",
      "up_runtime_task_layer_number": 0,
      "da": "local_da",
      "db": "local_db"
    })
    
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "c": "global_ccc",
      "up_runtime_task_layer_number": 0,
      "da": "local_da",
      "db": "local_db",
      "a": "local_aaa",
      "b": "local_bbb"
    })
    
    cmd( 1):
    echo "shell step1"
    
    -
    shell step1
    
    -
     .. ok
    cmd( 2):
    echo "shell step2"
    
    -
    shell step2
    
    -
     .. ok
    . ok
    -Step2:
    self: final context exec vars:
    
    (*core.Cache)({
      "a": "local_aaa",
      "b": "local_bbb",
      "c": "global_ccc",
      "last_result": (*utils.ExecResult)({
        Cmd: "echo \"shell step2\"",
        Code: 0,
        Output: "shell step2",
        ErrMsg: ""
      }),
      "up_runtime_task_layer_number": 0,
      "da": "local_da",
      "db": "local_db"
    })
    
    ~SubStep1: [print:  ]
    cmd print step
    up_runtime_task_layer_number: 0
    a: local_aaa
    b: local_bbb
    da: local_da
    db: local_db
    
    
Logs with different verbose level
Raw logs with different verbose level