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

     1  doc_meta: |
     2    folder: call-func
     3    title: call func as interface
     4    head: |
     5      This demos a design pattern using call and callee task without local vars
     6  
     7      The caller's varss should always take priority than the the callee's vars, if callee has already got same local vars defined, they will be overrided and used as default values
     8  
     9    sections:
    10      - title: Applications
    11        content: |
    12          The possible application of this pattern is to  call different implmentation task depending on certain condition, For example,
    13  
    14          1. you could conditionally deploy an application to AWS, Azure or K8s depending on criteria
    15  
    16          2. you could provistion backend storage solution using EBS, EFS
    17  
    18      - title: Demo
    19        log: yes
    20  
    21  notes:
    22    goal:
    23      - to show a design pattern using call and callee task without local vars
    24      - the caller's varss should always take priority than the the callee's vars, if callee has already got same local vars defined, they will be overrided and used as default values
    25  
    26  vars:
    27    school: sydney grammar
    28  
    29  tasks:
    30    -
    31      name: task
    32      task:
    33        -
    34          func: call
    35          desc: call function with different vars
    36          vars:
    37            studentname: Tom
    38            school: sydney grammar
    39            gender: male
    40          do:
    41            - function
    42  
    43    - name: function
    44      desc: |
    45        as a design pattern, this is a function task
    46        it's better to not to use any local vars, in this
    47        way, the vars are passed in from caller call so
    48        that this function could be used by multiple ref tasks
    49      task:
    50        -
    51          func: shell
    52          desc: show school and student info
    53          do:
    54            - echo "studentname -> {{.studentname}} | gender -> {{.gender}}"
    55            - echo "school -> {{.school}}"
    56