github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0042.yml (about) 1 doc_meta: | 2 folder: object-oriented 3 title: reg/deReg/void 4 head: | 5 You can use template func reg to register a value to global runtime or deReg to remove it from runtime 6 7 sections: 8 - title: Important note 9 content: | 10 reg will register the value into global runtime 11 12 If you do not need to use the dvar value instead of the register object, then use void as the dvar name, it will not create a new var and put into global runtime 13 14 You can always use void as the name of a dvar, so that the dvar is used more like action method to do things rather than rendering value 15 16 - title: Demo 17 log: yes 18 19 related: 20 refs: 21 - title: convert dvar 22 link: ../../dvars/c0027/ 23 24 notes: 25 goal: 26 - add feature to use .last_result to have a quick shortcut access to last task result 27 28 tasks: 29 30 - 31 name: task 32 desc: test the exit scenarios due to different types of validation 33 task: 34 - 35 func: shell 36 desc: step1 37 do: 38 - echo tom 39 - echo hanks 40 41 - 42 func: shell 43 desc: | 44 the last result of hanks will be registered as varname: hellomsg 45 dvars: 46 - name: reg_hello 47 value: | 48 hello: {{.last_result.Output|reg "hellomsg" }} 49 flags: 50 - v 51 do: 52 - echo "hellomsg - {{.hellomsg}}" 53 - echo "reg_hello - {{.reg_hello}}" 54 55 - 56 func: shell 57 desc: | 58 the hellomsg will be still availabe in this step 59 it is removed but will be unavailabe in the next step 60 dvars: 61 - name: reg_hello 62 value: | 63 {{deReg "hellomsg" }} 64 do: 65 - echo "{{.hellomsg}}" 66 67 - 68 func: shell 69 desc: | 70 now the hellomsg should be <no value> 71 do: 72 - echo "{{.hellomsg}}" 73 74 - 75 func: shell 76 dvars: 77 - name: void 78 desc: | 79 now this var name will not be shown in local automatically 80 or in global if you register it as it the reg template func 81 is more like a action and return sensible value 82 value: 'hello: {{ print "something" |reg "iamvoid" }}' 83 flags: [vvv] 84 do: 85 - echo '{{.iamvoid}}' 86 87 - 88 func: shell 89 do: 90 - echo '{{.iamvoid}}'