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

     1  doc_meta: |
     2    folder: dvars
     3    title: dynamics on dynamics
     4    head: |
     5      Showcase you can use multiple expansions to dynamically render a dvar
     6  
     7      Please note you can use plain raw value for dvar value, however it is better to manage the string constant as a configuration entry as a var item
     8  
     9    sections:
    10      - title: Demo
    11        log: yes
    12  
    13  notes:
    14    goal:
    15      - to show dynamic vars usage
    16      - you can use plain value in dvar, nothing preventing you doing so
    17      - remember dvar value normally already evaluated so be careful with expand level
    18  
    19  vars:
    20    school: Sydney Grammar
    21  
    22  dvars:
    23  
    24  #case 1: reference to dvar
    25    - name: nv
    26      value: "n=>{{.school}}"
    27  
    28    - name: m
    29      value: m=>{{.nv}}
    30      expand: 1
    31      desc: |
    32        the expand should be 1 as n is already instanciated a actual value
    33  
    34    - name: j
    35      value: j=>{{.m}}
    36      expand: 1
    37      desc: |
    38        the expand should be 1 as n is already instanciated a actual value
    39  
    40  #case 2: reference to var
    41    - name: o
    42      value: o=>{{.c}}
    43      expand: 3
    44      desc: |
    45        the expand should be 3 as the reference in vars not evaluated yet
    46        this eventually will be the value of school from vars
    47  
    48  #case 3: it allows you to put non templated string there as value in dvars
    49    - name: z
    50      value: i am zzz
    51      desc: you can use plain string here too
    52  
    53    - name: yv
    54      value: y->{{.z}}
    55  
    56    - name: x
    57      value: x=>{{.yv}}
    58      expand: 1
    59      desc: |
    60        you can't expect to use expand level 2 to get value z, as there is no need
    61        to do so because y should be already rendered
    62  
    63  tasks:
    64  
    65    - name: task
    66      task:
    67        -
    68          func: shell
    69          do:
    70            - echo "n->{{.nv}}"
    71            - echo "m->{{.m}}"
    72            - echo "j->{{.j}}"
    73            - echo "o->{{.o}}"
    74            - echo "z->{{.z}}"
    75            - echo "y->{{.yv}}"
    76            - echo "x->{{.x}}"