working directory

By default, you will be using current working directory for an execution of your task

Sometimes, we need a protected way or simly we need a jailed execution to where the task up.yml is located, in this case, we could config the working directory to be the refdir and in this case the refdir is out side of current directory

How it works

By default, the WorkDir setting is “cwd”, which is the current working directory you execute the up command

There are two ways doing it:

  • You can configure it in the upconfig.yml

    version: 1.0.0
    Verbose: v
    MaxCallLayers: 8
    RefDir: .
    WorkDir: refdir      -> use "refdir" to dictate the execution working directory will be in the refdir instead of current work dir
    TaskFile: up.yml
    ConfigDir: .
    ConfigFile: upconfig.yml
    
  • You can use cmd arg in CLI to specify that you want it to be refdir

  -w, --workdir=WORKDIR        working directory: cwd | refdir

  eg:
  up ngo task -d ./tests/functests -t wip.yml -i dev --configdir=./tests/functests -w refdir

Application using current directory as work directory

Normally, if you intend to do project based work, then you will need to use the default setting: cwd - current work directory as the working directory.

In this case, you cd to the project directory, all the directories in your up.yml will be reletive path to your project directory

Application using refdir

If the up.yml tasks are wrapped as a service to do something system wide and not relevent to your specific project, all the changes made in the task are confined within the refdir, than the WorkDir should be refdir

For example, you could use below alias: install_apps to install and update all your softwares, this task will manage to install all defined softwares and if it requires to caches some files and temp directories, it will put them into the refdir

alias install_apps='up ngo task -d /myapps/install_all_required_softwards -w refdir'

So, when you consider publish your own task(s) for other people to use as a standalone tool/cli cmd, you should use this setting

Demo

source

Main task yaml file
    tasks:
    - name: task
      desc: main entry
      task:
      - func: shell
        desc: main job
        do:
        - pwd
    
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 -> c0144
                 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/c0144
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task: main entry ]
    -Step1: [: main job ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 0
    })
    
    cmd( 1):
    pwd
    
    -
    /up_project/up
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level