None value

None value will be presented if there variable is not be to be rendered

Most of the case, this is due to the non-exist variable of given path

Demo

source

Main task yaml file
    vars:
      person:
        name: tom
    tasks:
    - name: task
      task:
      - func: cmd
        desc: |
          the commented if statement will cause a template rendering issue since person.school is not able to be determined
        do:
        - name: print
          cmd: "hello: {{.person.name}}"
      - func: cmd
        #        if: '{{eq .person.school "None"}}'
    
        desc: |
          correct way is to try to get the school value and save it to a dvar
          then it is deterministic of the school value
        dvars:
        - name: school
          value: '{{.person.school}}'
        do:
        - name: print
          cmd: "hello: {{.person.name}}"
        if: '{{eq .school "None"}}'
        else:
        - func: cmd
          desc: now it is safe to access school from person object
          do:
          - name: print
            cmd: "hello: {{.person.name}} from {{.person.school}}"
    
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 -> c0157
                 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/c0157
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1: [
    the commented if statement will cause a template rendering issue since person.school is not able to be determined
    ]
    self: final context exec vars:
    
    (*core.Cache)({
      "person": {
        "name": "tom"
      },
      "up_runtime_task_layer_number": 0
    })
    
    ~SubStep1: [print:  ]
    hello: tom
    -Step2: [
    correct way is to try to get the school value and save it to a dvar
    then it is deterministic of the school value
    ]
    self: final context exec vars:
    
    (*core.Cache)({
      "school": "None",
      "person": {
        "name": "tom"
      },
      "up_runtime_task_layer_number": 0
    })
    
    ~SubStep1: [print:  ]
    hello: tom
    
Logs with different verbose level
Raw logs with different verbose level

How to user the None value properly

  • Note that if you intend to evaluate the var’s value directly, in case of the var path does not exist, the variable part will be replace by golang internal instead of None
  • You should always use a var to store the direct var by given a variable path, eg. person.name