vars:
tom: this is tom
tasks:
- name: task
task:
- func: call
do: sub1
- func: cmd
desc: |
check if hitom is available in global context
it should be <no value> as hitom in sub1 is marked localOnly
do:
- name: print
cmd: '{{.hitom}}'
- func: call
do: sub2
- func: cmd
desc: |
check if hitom is available in global context
though hitom was regiser as global var, but it was registered to its own call stack
however this is only available in its own call stack global but not return and available to its parent var scope
do:
- name: print
cmd: '{{.hitom}}'
- name: sub1
task:
- func: cmd
do:
- name: reg
cmd:
name: hitom
desc: by default hitom is registered in to global context
value: 'hello, {{.tom}}'
flags: [localOnly]
- name: print
cmd: '{{.hitom}}'
- func: cmd
do:
- name: print
desc: should be <no value> since it is marked localOnly
cmd: '{{.hitom}}'
- name: sub2
task:
- func: cmd
do:
- name: reg
cmd:
name: hitom
desc: by default hitom is registered in to global context
value: 'hello, {{.tom}}'
- name: print
cmd: '{{.hitom}}'
- func: cmd
do:
- name: print
desc: |
by default hitom is accessible from global context, that's why it is accessiable cross func
however this is only available in its own call stack global but not return and available to its parent var scope
cmd: '{{.hitom}}'
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0106
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/c0106
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1:
self: final context exec vars:
(*core.Cache)({
"tom": "this is tom",
"up_runtime_task_layer_number": 0
})
=Task2: [task ==> sub1: ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"tom": "this is tom",
"up_runtime_task_layer_number": 1
})
~~SubStep1: [reg: ]
~~SubStep2: [print: ]
hello, this is tom
--Step2:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"tom": "this is tom"
})
~~SubStep1: [print: should be <no value> since it is marked localOnly ]
None
-Step2: [
check if hitom is available in global context
it should be <no value> as hitom in sub1 is marked localOnly
]
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"tom": "this is tom"
})
~SubStep1: [print: ]
None
-Step3:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"tom": "this is tom"
})
=Task3: [task ==> sub2: ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"tom": "this is tom",
"up_runtime_task_layer_number": 1
})
~~SubStep1: [reg: ]
~~SubStep2: [print: ]
hello, this is tom
--Step2:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"hitom": "hello, this is tom",
"tom": "this is tom"
})
~~SubStep1: [print: by default hitom is accessible from global context, that's why it is accessiable cross func
however this is only available in its own call stack global but not return and available to its parent var scope
]
hello, this is tom
-Step4: [
check if hitom is available in global context
though hitom was regiser as global var, but it was registered to its own call stack
however this is only available in its own call stack global but not return and available to its parent var scope
]
self: final context exec vars:
(*core.Cache)({
"tom": "this is tom",
"up_runtime_task_layer_number": 1
})
~SubStep1: [print: ]
None
Understanding of global vars scope in call stack
global vars scope is not unique, it is a concept of relative scope for its call stack. within that call stack, all changes(new registered global vars) will be valid only for its own stack in that call func only
use taskScope