In this case, we showcase to render dvar value using data field as source rather the global var name space
Please note the datakey tag is used and it is pointing to a variable named student. In this caes the reference of {{.school}} will locate the school from global runtime var: .student.school
Without this tag, the reference of {{.school}} will try to locate a var name school from global runtime
Please also note that the datakey could be a dynamic using var, this gives you a little extra programmingbility for dynamic routing when you combine with logical if tag
vars:
student:
name: Tom
gender: Male
school: Sydney Grammar
nsw:
sydney:
sgschool:
student:
name: Tom
gender: Male
school: Sydney Grammar
aaa: aaa
datapointer: student
tasks:
- name: task
task:
- func: cmd
dvars:
- name: student_info
value: 'my name is:{{.name}} and I am in {{.school}}'
datakey: student
flags: [vvv]
do:
- name: print
cmd: '{{.student_info}}'
- func: cmd
dvars:
- name: student_info
value: 'my name is:{{.name}} and I am in {{.school}}'
datakey: '{{.datapointer}}'
flags: [vvv]
do:
- name: print
cmd: '{{.student_info}}'
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0082
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/c0082
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1:
dvar> student_info:
"my name is:<no value> and I am in <no value>"
-
my name is:<no value> and I am in <no value>
self: final context exec vars:
(*core.Cache)({
"aaa": "aaa",
"datapointer": "student",
"up_runtime_task_layer_number": 0,
"student_info": "my name is:<no value> and I am in <no value>",
"student": {
"name": "Tom",
"gender": "Male",
"school": "Sydney Grammar"
},
"nsw": {
"sydney": {
"sgschool": {
"student": {
"name": "Tom",
"gender": "Male",
"school": "Sydney Grammar"
}
}
}
}
})
~SubStep1: [print: ]
my name is:<no value> and I am in <no value>
-Step2:
dvar> student_info:
"my name is:<no value> and I am in <no value>"
-
my name is:<no value> and I am in <no value>
self: final context exec vars:
(*core.Cache)({
"student": {
"gender": "Male",
"school": "Sydney Grammar",
"name": "Tom"
},
"nsw": {
"sydney": {
"sgschool": {
"student": {
"gender": "Male",
"school": "Sydney Grammar",
"name": "Tom"
}
}
}
},
"aaa": "aaa",
"datapointer": "student",
"up_runtime_task_layer_number": 0,
"student_info": "my name is:<no value> and I am in <no value>"
})
~SubStep1: [print: ]
my name is:<no value> and I am in <no value>