You can wrap the var name following golang template syntax to reference a var, eg .varname
Alternativelly, you can reference to a sub element of a object, eg sg.address to refer to the address of object of sg
vars:
school: sydney grammar
sg:
name: sydney grammar
address: Sydney, NSW 2000
tasks:
- name: task
task:
- func: shell
vars:
studentname: Tom
do:
- echo "studentname -> {{.studentname}}"
- echo "gender -> male"
- echo "school -> {{.school}}"
- echo "nonexist -> {{.notexist}}"
- echo "SG details -> {{.sg.name}}/{{.sg.address}}"
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0019
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/c0019
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1:
self: final context exec vars:
(*core.Cache)({
"sg": {
"name": "sydney grammar",
"address": "Sydney, NSW 2000"
},
"up_runtime_task_layer_number": 0,
"studentname": "Tom",
"school": "sydney grammar"
})
cmd( 1):
echo "studentname -> {{.studentname}}"
-
studentname -> Tom
-
.. ok
cmd( 2):
echo "gender -> male"
-
gender -> male
-
.. ok
cmd( 3):
echo "school -> {{.school}}"
-
school -> sydney grammar
-
.. ok
cmd( 4):
echo "nonexist -> {{.notexist}}"
-
nonexist -> <no value>
-
.. ok
cmd( 5):
echo "SG details -> {{.sg.name}}/{{.sg.address}}"
-
SG details -> sydney grammar/Sydney, NSW 2000
-
.. ok
. ok