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

     1  
     2  flow:
     3        - func: shell
     4          do:
     5            - echo "?intest ->  {{.intest}}"
     6            - pwd
     7          reg: register_render_root
     8  
     9        - func: cmd
    10          do:
    11            - name: print
    12              cmd: 'intest is: [{{.intest}}]'
    13  
    14            - name: reg
    15              cmd:
    16                name: correct_working_dir
    17                desc: the value of .intest is string but not bool so you can not simple use if .intest for condition
    18                value: >-
    19                  {{if eq .intest "true" }}{{.register_render_root.Output}}{{else}}{{.register_render_root.Output}}{{end}}
    20  
    21        - func: cmd
    22          do:
    23            - name: print
    24              cmd: 'root dir is: [{{.register_render_root.Output}}]'
    25  
    26            - name: print
    27              cmd: 'correct working dir is: [{{.correct_working_dir}}]'
    28  
    29        -
    30          func: cmd
    31          desc: render final result using template
    32          do:
    33            - name: template
    34              desc: render the template file using above dynamic variable from defined var
    35              cmd:
    36                src: '{{.correct_working_dir}}/tests/functests/d0079.template'
    37                dest: /tmp/myschool.txt
    38                datakey: "school_details_object"
    39  
    40        - func: cmd
    41          do:
    42            - name: readFile
    43              desc: read content of a file and register it to a var
    44              cmd:
    45                filename: myschool.txt
    46                dir: /tmp
    47                reg: my_school
    48  
    49            -
    50              name: print
    51              cmd: "{{.my_school}}"