github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0147.yml (about) 1 doc_meta: | 2 folder: vars 3 title: use pure local vars 4 head: | 5 This showcases that you can use pure local vars without extending the scope vars and global vars 6 7 sections: 8 - title: What's the use cae of this 9 content: | 10 Sometimes, you want all the local vars to be pure and entired isolated in its own context, then you can setup a flag - pure to protect the local vars not to be impacted by the merging process 11 12 In this case, the local vars and its sub call stack's var stack will be all protected because the sub stack will be an extention of this func call 13 14 - title: Demo 15 log: yes 16 17 notes: 18 - add support to use pure local vars without global var scope 19 20 vars: 21 a: aaa 22 b: bbb-global 23 c: ccc 24 25 tasks: 26 - name: task 27 desc: mock up test to test module.template rendering 28 task: 29 - func: cmd 30 vars: 31 b: bbb 32 d: ddd 33 flags: 34 - pure 35 do: 36 - 37 name: inspect 38 desc: the vars in caller after invoking module task 39 cmd: 40 - exec_vars 41 - exec_base_vars 42 - 43 name: assert 44 cmd: 45 - '{{eq .b "bbb"}}' 46 - '{{eq .d "ddd"}}' 47 48 - func: call 49 vars: 50 e: first_level_eee 51 f: first_level_fff 52 flags: 53 - pure 54 do: substack 55 56 - name: substack 57 task: 58 - func: cmd 59 vars: 60 f: fff 61 g: ggg 62 h: hhh 63 do: 64 - 65 name: inspect 66 desc: the vars in caller after invoking module task 67 cmd: 68 - exec_vars 69 - exec_base_vars 70 - 71 name: assert 72 cmd: 73 - '{{eq .f "first_level_fff"}}' 74 - '{{eq .e "first_level_eee"}}' 75 - '{{eq .g "ggg"}}'