github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0086.yml (about)

     1  doc_meta: |
     2    folder: dvars
     3    title: void for action
     4    head: |
     5      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
     6  
     7    sections:
     8      - title: Demo
     9        log: yes
    10  
    11    related:
    12      refs:
    13        - title: reg and void
    14          link: ../../template/c0042
    15  notes:
    16    goal:
    17      - |
    18        add feature dvar void var, which is a name that doing something, eg reg a var but makes no sense to be used globally at all
    19  
    20  vars:
    21    lines: |-
    22      hello
    23      this
    24      is a
    25      beautiful world
    26  
    27  tasks:
    28    -
    29      name: task
    30      desc: generate logs
    31      task:
    32  
    33        -
    34          func: shell
    35          dvars:
    36            - name: linelist
    37              desc: |
    38                it does not make sense that the result in local of linelist is empty
    39                so we do not need this var to be registered either in local or global
    40              value: '{{ .lines | splitLines | reg "linelist_object" }}'
    41              flags: [vvv]
    42          do:
    43            - echo '{{.lines}}'
    44            - echo '{{.linelist}}'
    45            - echo '{{.linelist_object}}'
    46  
    47        -
    48          func: shell
    49          dvars:
    50            - name: void
    51              desc: |
    52                now this var name will not be shown in local automatically
    53                or in global if you register it
    54              value: '{{ .lines | splitLines | reg "linelist_object" }}'
    55              flags: [vvv]
    56          do:
    57            - echo '{{.lines}}'
    58            - echo '{{.linelist}}'
    59            - echo '{{.linelist_object}}'
    60  
    61        -
    62          func: shell
    63          dvars:
    64            - name: void
    65              desc: |
    66                now this var name will not be shown in local automatically
    67                or in global if you register it
    68              value: '{{ .lines | splitLines | reg "linelist_object" }}'
    69              flags: [vvv, reg]
    70          do:
    71            - echo '{{.lines}}'
    72            - echo '{{.linelist}}'
    73            - echo '{{.linelist_object}}'
    74  
    75        -
    76          func: shell
    77          do:
    78            - echo '{{.lines}}'
    79            - echo '{{.linelist}}'
    80            - echo '{{.linelist_object}}'
    81  
    82        -
    83          func: shell
    84          dvars:
    85            - name: void
    86              desc: |
    87                now this var name will not be shown in local automatically
    88                or in global if you register it
    89              value: |-
    90                person:
    91                  name: tom
    92                  age: "18"
    93              flags: [vvv, reg, toObj]