instance level merge
Demo dvars leave level merge in scope and instance level
Note
- dvars expand in instance level
- dvars object can merge in leaf level
- dvar in dev will override same name dvar in nonprod level
- school object in nonprod could append new element and also override same name element
Demo
source
Main task yaml file
scopes:
- name: global
vars:
student:
name: Tom
gender: Male
address:
suburb:
name: sydney
postcode: 2000
CBD: yes
school: Sydney Grammar
- name: nonprod
members:
- dev
- staging
vars:
a: non-prod-a
b: non-prod-b
c: non-prod-c
d: non-prod-d
dvars:
- name: school
value: |
address:
suburb:
name: {{.student.address.suburb.name}}
postcode: 2000
CBD: yes
school: {{.student.address.school}}
flags: [toObj]
- name: dev
vars:
a: dev-a
b: dev-b
dvars:
- name: school
value: |
address:
suburb:
name: {{.student.address.suburb.name}}
postcode: 2000
CBD: no
school: {{.student.address.school}}
principal: Mr Peter
flags: [toObj]
tasks:
- name: task
task:
- func: shell
do:
- echo """1.school -> {{.school}}"""
- echo """2.school object-> {{.school_object.address.suburb.CBD}}"""
- echo """3.school object-> {{.school_object.address.school}}"""
- echo """4.school object-> {{.school_object.principal}}"""
Main log file
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0032
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/c0032
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1:
self: final context exec vars:
(*core.Cache)({
"b": "dev-b",
"school": "address:\n suburb:\n name: sydney\n postcode: 2000\n CBD: no\n school: Sydney Grammar\nprincipal: Mr Peter\n",
"school_object": {
"principal": "Mr Peter",
"address": {
"suburb": {
"postcode": 2000,
"CBD": false,
"name": "sydney"
},
"school": "Sydney Grammar"
}
},
"up_runtime_task_layer_number": 0,
"student": {
"name": "Tom",
"gender": "Male",
"address": {
"suburb": {
"CBD": true,
"name": "sydney",
"postcode": 2000
},
"school": "Sydney Grammar"
}
},
"c": "non-prod-c",
"d": "non-prod-d",
"a": "dev-a"
})
cmd( 1):
echo """1.school -> {{.school}}"""
-
1.school -> address:
suburb:
name: sydney
postcode: 2000
CBD: no
school: Sydney Grammar
principal: Mr Peter
-
.. ok
cmd( 2):
echo """2.school object-> {{.school_object.address.suburb.CBD}}"""
-
2.school object-> false
-
.. ok
cmd( 3):
echo """3.school object-> {{.school_object.address.school}}"""
-
3.school object-> Sydney Grammar
-
.. ok
cmd( 4):
echo """4.school object-> {{.school_object.principal}}"""
-
4.school object-> Mr Peter
-
.. ok
. ok
Logs with different verbose level
Raw logs with different verbose level