gtf funcs

Demo usecases of gtf golang template functions

gtf is a useful set of Golang Template Functions. The goal of this project is implementing all built-in template filters of Django & Jinja2

Demo

source

Main task yaml file
    vars:
      ns: prod
      pod_name: web_app
      ha: true
      age: 34
      old: 54
      admins: [tom, jason, alice]
      managers:
      - tom
      - jason
      - alice
      student:
        name: Tom
        gender: Male
        teachers:
        - tom
        - jason
        - alice
        address:
          suburb:
            name: sydney
            postcode: 2000
            CBD: yes
          school: Sydney Grammar
    dvars:
    - name: sprig_trim
      value: '{{ trim "  hello       "}}'
      desc: test if sprig is still working
      flags: [vvvv]
    - name: var_slice_index
      desc: check if the builtin is still working
      value: "{{ index .admins 1 }}"
      flags: [vvvv]
    - name: gtf_url_encoding
      value: '{{ "http://www.example.org/foo?a=b&c=d" | urlencode}}'
      flags: [vvvv]
    - name: gtf_ljust
      value: '{{ hello | ljust 20}}'
      flags: [vvvv]
    tasks:
    - name: task
      task:
      - func: shell
        do:
        - echo "check the value of other dvar using vvvv flag print out"
    
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 -> c0038
                 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/c0038
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    dvar> sprig_trim:
    "hello"
    
    -
    hello
    dvar> var_slice_index:
    "jason"
    
    -
    jason
    dvar> gtf_url_encoding:
    "http%3A%2F%2Fwww.example.org%2Ffoo%3Fa%3Db%26c%3Dd"
    
    -
    http%3A%2F%2Fwww.example.org%2Ffoo%3Fa%3Db%26c%3Dd
    dvar> gtf_ljust:
    "Hello!              "
    
    -
    Hello!              
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 0,
      "var_slice_index": "jason",
      "managers": {
        "tom",
        "jason",
        "alice"
      },
      "pod_name": "web_app",
      "ha": true,
      "admins": {
        "tom",
        "jason",
        "alice"
      },
      "gtf_ljust": "Hello!              ",
      "ns": "prod",
      "old": 54,
      "gtf_url_encoding": "http%3A%2F%2Fwww.example.org%2Ffoo%3Fa%3Db%26c%3Dd",
      "sprig_trim": "hello",
      "age": 34,
      "student": {
        "name": "Tom",
        "gender": "Male",
        "teachers": {
          "tom",
          "jason",
          "alice"
        },
        "address": {
          "suburb": {
            "cbd": true,
            "name": "sydney",
            "postcode": 2000
          },
          "school": "Sydney Grammar"
        }
      }
    })
    
    cmd( 1):
    echo "check the value of other dvar using vvvv flag print out"
    
    -
    check the value of other dvar using vvvv flag print out
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level

Other references: