void for action
Showcase that you can use void as name of a dvar in case your intention is to use golang template func for an action rather than just rendering
Demo
source
Main task yaml file
vars:
lines: |-
hello
this
is a
beautiful world
tasks:
- name: task
desc: generate logs
task:
- func: shell
dvars:
- name: linelist
desc: |
it does not make sense that the result in local of linelist is empty
so we do not need this var to be registered either in local or global
value: '{{ .lines | splitLines | reg "linelist_object" }}'
flags: [vvv]
do:
- echo '{{.lines}}'
- echo '{{.linelist}}'
- echo '{{.linelist_object}}'
- func: shell
dvars:
- name: void
desc: |
now this var name will not be shown in local automatically
or in global if you register it
value: '{{ .lines | splitLines | reg "linelist_object" }}'
flags: [vvv]
do:
- echo '{{.lines}}'
- echo '{{.linelist}}'
- echo '{{.linelist_object}}'
- func: shell
dvars:
- name: void
desc: |
now this var name will not be shown in local automatically
or in global if you register it
value: '{{ .lines | splitLines | reg "linelist_object" }}'
flags: [vvv, reg]
do:
- echo '{{.lines}}'
- echo '{{.linelist}}'
- echo '{{.linelist_object}}'
- func: shell
do:
- echo '{{.lines}}'
- echo '{{.linelist}}'
- echo '{{.linelist_object}}'
- func: shell
dvars:
- name: void
desc: |
now this var name will not be shown in local automatically
or in global if you register it
value: |-
person:
name: tom
age: "18"
flags: [vvv, reg, toObj]
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 -> c0086
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/c0086
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: generate logs ]
-Step1:
dvar> linelist:
"- hello\n- this\n- is a\n- beautiful world\n"
-
- hello
- this
- is a
- beautiful world
self: final context exec vars:
(*core.Cache)({
"lines": "hello\nthis\nis a\nbeautiful world",
"up_runtime_task_layer_number": 0,
"linelist_object": {
"hello",
"this",
"is a",
"beautiful world"
},
"linelist": "- hello\n- this\n- is a\n- beautiful world\n"
})
cmd( 1):
echo '{{.lines}}'
-
hello
this
is a
beautiful world
-
.. ok
cmd( 2):
echo '{{.linelist}}'
-
- hello
- this
- is a
- beautiful world
-
.. ok
cmd( 3):
echo '{{.linelist_object}}'
-
[hello this is a beautiful world]
-
.. ok
. ok
-Step2:
dvar> void:
"- hello\n- this\n- is a\n- beautiful world\n"
-
- hello
- this
- is a
- beautiful world
self: final context exec vars:
(*core.Cache)({
"last_result": (*utils.ExecResult)({
Cmd: "echo '[hello this is a beautiful world]'",
Code: 0,
Output: "[hello this is a beautiful world]",
ErrMsg: ""
}),
"up_runtime_task_layer_number": 0,
"lines": "hello\nthis\nis a\nbeautiful world",
"linelist_object": {
"hello",
"this",
"is a",
"beautiful world"
}
})
cmd( 1):
echo '{{.lines}}'
-
hello
this
is a
beautiful world
-
.. ok
cmd( 2):
echo '{{.linelist}}'
-
<no value>
-
.. ok
cmd( 3):
echo '{{.linelist_object}}'
-
[hello this is a beautiful world]
-
.. ok
. ok
-Step3:
dvar> void:
"- hello\n- this\n- is a\n- beautiful world\n"
-
- hello
- this
- is a
- beautiful world
self: final context exec vars:
(*core.Cache)({
"lines": "hello\nthis\nis a\nbeautiful world",
"linelist_object": {
"hello",
"this",
"is a",
"beautiful world"
},
"last_result": (*utils.ExecResult)({
Cmd: "echo '[hello this is a beautiful world]'",
Code: 0,
Output: "[hello this is a beautiful world]",
ErrMsg: ""
}),
"up_runtime_task_layer_number": 0
})
cmd( 1):
echo '{{.lines}}'
-
hello
this
is a
beautiful world
-
.. ok
cmd( 2):
echo '{{.linelist}}'
-
<no value>
-
.. ok
cmd( 3):
echo '{{.linelist_object}}'
-
[hello this is a beautiful world]
-
.. ok
. ok
-Step4:
self: final context exec vars:
(*core.Cache)({
"linelist_object": {
"hello",
"this",
"is a",
"beautiful world"
},
"last_result": (*utils.ExecResult)({
Cmd: "echo '[hello this is a beautiful world]'",
Code: 0,
Output: "[hello this is a beautiful world]",
ErrMsg: ""
}),
"up_runtime_task_layer_number": 0,
"lines": "hello\nthis\nis a\nbeautiful world"
})
cmd( 1):
echo '{{.lines}}'
-
hello
this
is a
beautiful world
-
.. ok
cmd( 2):
echo '{{.linelist}}'
-
<no value>
-
.. ok
cmd( 3):
echo '{{.linelist_object}}'
-
[hello this is a beautiful world]
-
.. ok
. ok
-Step5:
dvar> void:
"person:\n name: tom\n age: \"18\""
-
person:
name: tom
age: "18"
WARN: [?reg a void] - [you can't register a object with void name, use a proper name instead or split to multiple steps]
dvar[object]> void_object:
{
"person": {
"name": "tom",
"age": "18"
}
}
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0,
"lines": "hello\nthis\nis a\nbeautiful world",
"linelist_object": {
"hello",
"this",
"is a",
"beautiful world"
},
"last_result": (*utils.ExecResult)({
Cmd: "echo '[hello this is a beautiful world]'",
Code: 0,
Output: "[hello this is a beautiful world]",
ErrMsg: ""
})
})
WARN: [shell] - [Not implemented or void for no action!]
. ok
Logs with different verbose level
Raw logs with different verbose level
Other references: