templating using datakey and datapath
goal:
- showcase the dvar to render value using sub element of an var rather the global
var name space
- extension to c0082 and c0098
vars:
student:
name: Tom
gender: Male
school: Sydney Grammar
nsw:
sydney:
sgschool:
student:
name: Grace
gender: Female
school: MLC
tasks:
- name: task
task:
- func: cmd
desc: use datatemplate as datasource
dvars:
- name: student_info
value: 'my name is:{{.name}} and I am in {{.school}}'
datatemplate: |
name: {{.nsw.sydney.sgschool.student.name}}
gender: {{.nsw.sydney.sgschool.student.gender}}
school: {{.nsw.sydney.sgschool.student.school}}
flags: [vvv]
do:
- name: print
cmd: '{{.student_info}}'
- func: cmd
desc: use datatemplate as datasource
dvars:
- name: student_info
value: 'my name is:{{.student.name}} and I am in {{.school.name}}'
datatemplate: |
student:
name: {{.nsw.sydney.sgschool.student.name}}
gender: {{.nsw.sydney.sgschool.student.gender}}
school:
name: {{.nsw.sydney.sgschool.student.school}}
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 -> c0099
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/c0099
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1: [: use datatemplate as datasource ]
dvar> student_info:
"my name is:Grace and I am in MLC"
-
my name is:Grace and I am in MLC
self: final context exec vars:
(*core.Cache)({
"student_info": "my name is:Grace and I am in MLC",
"student": {
"gender": "Male",
"school": "Sydney Grammar",
"name": "Tom"
},
"nsw": {
"sydney": {
"sgschool": {
"student": {
"gender": "Female",
"school": "MLC",
"name": "Grace"
}
}
}
},
"up_runtime_task_layer_number": 0
})
~SubStep1: [print: ]
my name is:Grace and I am in MLC
-Step2: [: use datatemplate as datasource ]
dvar> student_info:
"my name is:Grace and I am in MLC"
-
my name is:Grace and I am in MLC
self: final context exec vars:
(*core.Cache)({
"nsw": {
"sydney": {
"sgschool": {
"student": {
"gender": "Female",
"school": "MLC",
"name": "Grace"
}
}
}
},
"student": {
"gender": "Male",
"school": "Sydney Grammar",
"name": "Tom"
},
"up_runtime_task_layer_number": 0,
"student_info": "my name is:Grace and I am in MLC"
})
~SubStep1: [print: ]
my name is:Grace and I am in MLC