templating using dvar

Showcase how to use external tool, eg shell script to tempate content

template dynamic content

Note that the content of school_address is templated from defined global runtime var

address:
  suburb:
    name: {{.student.address.suburb.name}}
    postcode: 2000
    CBD: yes
  school: {{.student.address.school}}

The rendered content is dumped to a file and shown afterwards

Demo

source

Main task yaml file
    vars:
      student:
        name: Tom
        gender: Male
        address:
          suburb:
            name: sydney
            postcode: 2000
            CBD: yes
          school: Sydney Grammar
    dvars:
    - name: school_address
      ref: d0069.yml
    tasks:
    - name: task
      task:
      - func: shell
        do:
        - echo """school address {{.school_address}}"""
        - echo """school address {{.school_address}}""" > /tmp/school.txt
        - cat /tmp/school.txt
    
Main log file
    loading [Config]:  ./tests/functests/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/functests
                 WorkDir -> cwd
              AbsWorkDir -> /up_project/up
                TaskFile -> c0069
                 Verbose -> vvv
              ModuleName -> self
               ShellType -> /bin/sh
           MaxCallLayers -> 8
                 Timeout -> 3600000
     MaxModuelCallLayers -> 256
               EntryTask -> task
      ModRepoUsernameRef -> 
      ModRepoPasswordRef -> 
    work dir: /up_project/up
    -exec task: task
    loading [Task]:  ./tests/functests/c0069
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "school_address": "address:\n  suburb:\n    name: sydney\n    postcode: 2000\n    CBD: yes\n  school: Sydney Grammar\n",
      "student": {
        "name": "Tom",
        "gender": "Male",
        "address": {
          "school": "Sydney Grammar",
          "suburb": {
            "cbd": true,
            "name": "sydney",
            "postcode": 2000
          }
        }
      },
      "up_runtime_task_layer_number": 0
    })
    
    cmd( 1):
    echo """school address {{.school_address}}"""
    
    -
    school address address:
      suburb:
        name: sydney
        postcode: 2000
        CBD: yes
      school: Sydney Grammar
    
    
    -
     .. ok
    cmd( 2):
    echo """school address {{.school_address}}""" > /tmp/school.txt
    
    -
    
    -
     .. ok
    cmd( 3):
    cat /tmp/school.txt
    
    -
    school address address:
      suburb:
        name: sydney
        postcode: 2000
        CBD: yes
      school: Sydney Grammar
    
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level