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

     1  doc_meta: |
     2    folder: scope
     3    title: externalize settings
     4    head: |
     5      This demos how to externalize the lengthy vars configuration to a reference file, load it during the runtime
     6  
     7    sections:
     8      - title: Why
     9        content: |
    10          It is ok to just put the a few vars configuration entries together in paralelle with tasks in one yml file. With project growing, we offten need to make the code tidy, clean and modulized. In our case, it refers to yml configurations. It will significantlly reduce the line of codes before you could have a quick glimpse of skeleton of the tasks
    11  
    12          In this demo, we show that the global vars all go to the referece yml file in refdir. The refdir could be a global configurable settting apply to all
    13  
    14      - title: Application
    15        content: |
    16          You could configure the group relationship in scope element and offload the details to separate files
    17  
    18          For example: You could use follow directory structure to manage your vars:
    19  
    20          ```
    21          scope:\
    22              global.yml          -> store all global vars
    23              prod:\              -> prod group
    24                dr:\
    25                  dr.yml
    26                prod:\
    27                  prod.yml
    28                  db.yml
    29              nonprod:\           -> nonprod group
    30                dev:\
    31                  dev.yml         -> dev settings
    32                st:\
    33                  st.yml
    34                staging:\
    35                  staging.yml
    36                db.yml            -> common db setttings for all nonprod group
    37            ```
    38  
    39      - title: d0009-global.yml reference
    40        filelookup: d0009-global.yml
    41  
    42      - title: d0009-dev.yml reference
    43        filelookup: d0009-dev.yml
    44  
    45      - title: Demo
    46        log: yes
    47  
    48  notes:
    49    goal:
    50      - to test out vars reference in yml file
    51      - refdir in scope itme can not be dynamic value as the scope is very fundamental
    52  
    53  scopes:
    54    -
    55      name: global
    56      ref: d0009-global.yml
    57      refdir: ./tests/functests
    58  
    59    -
    60      name: prod
    61      members: [dr,prod]
    62      vars:
    63        a: prod-a
    64        c: prod-c
    65  
    66    -
    67      name: nonprod
    68      members:
    69        - dev
    70        - st
    71        - staging
    72      vars:
    73        a: non-prod-a
    74        b: non-prod-b
    75        c: non-prod-c
    76  
    77    -
    78      name: staging
    79      vars:
    80        a: staging-a
    81        b: staging-b
    82  
    83    -  name: dev
    84       ref: d0009-dev.yml
    85  
    86  tasks:
    87  
    88    -
    89      name: task
    90      task:
    91        -
    92          func: shell
    93          do:
    94            - echo "test out the var scopes only"
    95