reg will register the value into global runtime
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
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
tasks:
- name: task
desc: test the exit scenarios due to different types of validation
task:
- func: shell
desc: step1
do:
- echo tom
- echo hanks
- func: shell
desc: |
the last result of hanks will be registered as varname: hellomsg
dvars:
- name: reg_hello
value: |
hello: {{.last_result.Output|reg "hellomsg" }}
flags:
- v
do:
- echo "hellomsg - {{.hellomsg}}"
- echo "reg_hello - {{.reg_hello}}"
- func: shell
desc: |
the hellomsg will be still availabe in this step
it is removed but will be unavailabe in the next step
dvars:
- name: reg_hello
value: |
{{deReg "hellomsg" }}
do:
- echo "{{.hellomsg}}"
- func: shell
desc: |
now the hellomsg should be <no value>
do:
- echo "{{.hellomsg}}"
- func: shell
dvars:
- name: void
desc: |
now this var name will not be shown in local automatically
or in global if you register it as it the reg template func
is more like a action and return sensible value
value: 'hello: {{ print "something" |reg "iamvoid" }}'
flags: [vvv]
do:
- echo '{{.iamvoid}}'
- func: shell
do:
- echo '{{.iamvoid}}'
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0042
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/c0042
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: test the exit scenarios due to different types of validation ]
-Step1: [: step1 ]
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0
})
cmd( 1):
echo tom
-
tom
-
.. ok
cmd( 2):
echo hanks
-
hanks
-
.. ok
. ok
-Step2: [
the last result of hanks will be registered as varname: hellomsg
]
dvar> reg_hello:
"hello: hanks\n\n"
-
hello: hanks
self: final context exec vars:
(*core.Cache)({
"last_result": (*utils.ExecResult)({
Cmd: "echo hanks",
Code: 0,
Output: "hanks",
ErrMsg: ""
}),
"up_runtime_task_layer_number": 0,
"hellomsg": "hanks",
"reg_hello": "hello: hanks\n\n"
})
cmd( 1):
echo "hellomsg - {{.hellomsg}}"
-
hellomsg - hanks
-
.. ok
cmd( 2):
echo "reg_hello - {{.reg_hello}}"
-
reg_hello - hello: hanks
-
.. ok
. ok
-Step3: [
the hellomsg will be still availabe in this step
it is removed but will be unavailabe in the next step
]
self: final context exec vars:
(*core.Cache)({
"hellomsg": "hanks",
"last_result": (*utils.ExecResult)({
Cmd: "echo \"reg_hello - hello: hanks\n\n\"",
Code: 0,
Output: "reg_hello - hello: hanks",
ErrMsg: ""
}),
"up_runtime_task_layer_number": 0,
"reg_hello": "\n"
})
cmd( 1):
echo "{{.hellomsg}}"
-
hanks
-
.. ok
. ok
-Step4: [
now the hellomsg should be <no value>
]
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0,
"last_result": (*utils.ExecResult)({
Cmd: "echo \"hanks\"",
Code: 0,
Output: "hanks",
ErrMsg: ""
})
})
cmd( 1):
echo "{{.hellomsg}}"
-
<no value>
-
.. ok
. ok
-Step5:
dvar> void:
"hello: something\n"
-
hello: something
self: final context exec vars:
(*core.Cache)({
"last_result": (*utils.ExecResult)({
Cmd: "echo \"<no value>\"",
Code: 0,
Output: "<no value>",
ErrMsg: ""
}),
"up_runtime_task_layer_number": 0,
"iamvoid": "something"
})
cmd( 1):
echo '{{.iamvoid}}'
-
something
-
.. ok
. ok
-Step6:
self: final context exec vars:
(*core.Cache)({
"last_result": (*utils.ExecResult)({
Cmd: "echo 'something'",
Code: 0,
Output: "something",
ErrMsg: ""
}),
"iamvoid": "something",
"up_runtime_task_layer_number": 0
})
cmd( 1):
echo '{{.iamvoid}}'
-
something
-
.. ok
. ok