Sometimes, you want all the local vars to be pure and entired isolated in its own context, then you can setup a flag - pure to protect the local vars not to be impacted by the merging process
In this case, the local vars and its sub call stack’s var stack will be all protected because the sub stack will be an extention of this func call
vars:
a: aaa
b: bbb-global
c: ccc
tasks:
- name: task
desc: mock up test to test module.template rendering
task:
- func: cmd
vars:
b: bbb
d: ddd
flags:
- pure
do:
- name: inspect
desc: the vars in caller after invoking module task
cmd:
- exec_vars
- exec_base_vars
- name: assert
cmd:
- '{{eq .b "bbb"}}'
- '{{eq .d "ddd"}}'
- func: call
vars:
e: first_level_eee
f: first_level_fff
flags:
- pure
do: substack
- name: substack
task:
- func: cmd
vars:
f: fff
g: ggg
h: hhh
do:
- name: inspect
desc: the vars in caller after invoking module task
cmd:
- exec_vars
- exec_base_vars
- name: assert
cmd:
- '{{eq .f "first_level_fff"}}'
- '{{eq .e "first_level_eee"}}'
- '{{eq .g "ggg"}}'
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0147
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/c0147
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: mock up test to test module.template rendering ]
-Step1:
self: final context exec vars:
(*core.Cache)({
"d": "ddd",
"b": "bbb",
"up_runtime_task_layer_number": 0
})
~SubStep1: [inspect: the vars in caller after invoking module task ]
1: inspect[exec_vars]
(*core.Cache)({
"up_runtime_task_layer_number": 0,
"d": "ddd",
"b": "bbb"
})
2: inspect[exec_base_vars]
{
"b": "bbb-global",
"c": "ccc",
"a": "aaa"
}
~SubStep2: [assert: ]
1 ASSERT OK: [{{eq .b "bbb"}}]
2 ASSERT OK: [{{eq .d "ddd"}}]
-Step2:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0,
"e": "first_level_eee",
"f": "first_level_fff"
})
=Task2: [task ==> substack: ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1,
"f": "first_level_fff",
"g": "ggg",
"h": "hhh",
"e": "first_level_eee"
})
~~SubStep1: [inspect: the vars in caller after invoking module task ]
1: inspect[exec_vars]
(*core.Cache)({
"h": "hhh",
"e": "first_level_eee",
"up_runtime_task_layer_number": 1,
"f": "first_level_fff",
"g": "ggg"
})
2: inspect[exec_base_vars]
{
"up_runtime_task_layer_number": 0,
"e": "first_level_eee",
"f": "first_level_fff"
}
~~SubStep2: [assert: ]
1 ASSERT OK: [{{eq .f "first_level_fff"}}]
2 ASSERT OK: [{{eq .e "first_level_eee"}}]
3 ASSERT OK: [{{eq .g "ggg"}}]