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

     1  doc_meta: |
     2    folder: vars
     3    title: use vars
     4    head: |
     5      Demo basic usage of vars in shell func
     6  
     7      You can wrap the var name following golang template syntax to reference a var, eg .varname
     8  
     9      Alternativelly, you can reference to a sub element of a object, eg sg.address to refer to the address of object of sg
    10  
    11    sections:
    12      - title: Demo
    13        log: yes
    14  
    15  notes:
    16    goal:
    17      - to test out using vars using template
    18  
    19  vars:
    20    school: sydney grammar
    21    sg:
    22      name: sydney grammar
    23      address: Sydney, NSW 2000
    24  
    25  tasks:
    26    -
    27      name: task
    28      task:
    29        -
    30          func: shell
    31          vars:
    32            studentname: Tom
    33          do:
    34            - echo "studentname -> {{.studentname}}"
    35            - echo "gender -> male"
    36            - echo "school -> {{.school}}"
    37            - echo "nonexist -> {{.notexist}}"
    38            - echo "SG details -> {{.sg.name}}/{{.sg.address}}"
    39