A caller step invoke(call) a callee task is exactly comparable to a function/method call in many programming languages, caller pass in the vars from within its own vars scope and overrides the local vars defined in callee task
It is a design pattern to separate the intention and implementation, so actually the call func will serve like a interface just like it is in programming languages
vars:
a: runtime-a
e: runtime-e
k: runtime-k
tasks:
- name: callee_task
desc: this is ref-task
task:
- func: shell
vars:
a: callee-a
b: callee-b
c: callee-c
do:
- echo "exec ref-task"
- |
echo """
vars:
a: {{.a}}
b: {{.b}}
c: {{.c}}
e: {{.e}}
k: {{.k}}
"""
- name: task
desc:
task:
- func: call
vars:
a: caller-ref-a
b: caller-ref-b
do:
- callee_task
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0014
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/c0014
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task2: [task ==> task: ]
-Step1:
self: final context exec vars:
(*core.Cache)({
"b": "caller-ref-b",
"a": "caller-ref-a",
"e": "runtime-e",
"k": "runtime-k",
"up_runtime_task_layer_number": 0
})
=Task1: [task ==> callee_task: this is ref-task ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"e": "runtime-e",
"k": "runtime-k",
"up_runtime_task_layer_number": 1,
"c": "callee-c",
"a": "caller-ref-a",
"b": "caller-ref-b"
})
cmd( 1):
echo "exec ref-task"
-
exec ref-task
-
.. ok
cmd( 2):
echo """
vars:
a: {{.a}}
b: {{.b}}
c: {{.c}}
e: {{.e}}
k: {{.k}}
"""
-
vars:
a: caller-ref-a
b: caller-ref-b
c: callee-c
e: runtime-e
k: runtime-k
-
.. ok
. ok
- callee-task exec vars: |
{
"a": "callee-a",
"e": "runtime-e",
"b": "callee-b",
"c": "callee-c",
"k": "runtime-k"
}
- caller-task exec vars: |
(*cache.Cache)({
"k": "runtime-k",
"a": "caller-ref-a",
"e": "runtime-e",
"b": "caller-ref-b"
})
- result expected: |
caller vars will override callee's
(*cache.Cache)({
"b": "caller-ref-b",
"c": "callee-c",
"k": "runtime-k",
"a": "caller-ref-a",
"e": "runtime-e"
})