jailed exec context

Showcase that the execution context for module will be jaied in its own exontext based on its own configuration or default settings

source

How does it work?

In this case, you will see: * Even though the same name of “internal_task” presents in both caller and module task file, the call func will locate the right one within its own execution context.

  • You can see that the shell executions are all relevant to its own workdir, but will not be influenced by its caller. This guarantees the stability and certainty of third party module, with this feature, community members can collaborate together to come out of shared modules easily with predictable results

config file - upconfig.yml

    
    version: 1.0.0
    Verbose: v
    MaxCallLayers: 8
    RefDir: .
    TaskFile: up.yml
    ConfigDir: .
    ConfigFile: upconfig.yml
    
    Modules:
    
       #if there is no repo, then it will use the dir as module and incorporate as module
      - dir: hello-module/
        alias: hello-module
    

up task - up.yml

    tasks:
      -
        name: Main
        desc: main entry
        task:
    
          -
            func: call
            do: internal_task
    
    
          -
            func: call
            do: hello-module.Say_world
    
          -
            func: call
            do: internal_task
    
    
      -
        name: internal_task
        task:
          -
            func: cmd
            do:
              - name: print
                cmd: "this is a internal task in caller"
    
          -
            func: shell
            do:
              - ls -lart
              - ls |grep up
              - pwd
              - ls ../..|grep modtests
    

up module task - up.yml

    
    tasks:
    
      -
        name: Say_world
        task:
          -
            func: shell
            do:
              - ls -lart
              - ls |grep up
              - pwd
              - ls ../../..|grep modtests
    
          -
            func: call
            desc: |
              this should call its own internal task
            do: internal_task
    
      -
        name: Main
        desc: main entry
        task:
          -
            func: shell
            desc: main job
            do:
              - 'echo "hello world"'
    
          -
            func: call
            do: internal_task
    
      -
        name: internal_task
        task:
          -
            func: cmd
            do:
              - name: print
                cmd: "this is a internal task in module"
    
          -
            func: shell
            do:
              - ls -lart
              - ls |grep up
              - pwd
              - ls ../../..|grep modtests
    
Main log file
    loading [Config]:  ./tests/modtests/0004/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/modtests/0004
                 WorkDir -> refdir
              AbsWorkDir -> /up_project/up/tests/modtests/0004
                TaskFile -> up.yml
                 Verbose -> v
              ModuleName -> self
               ShellType -> /bin/sh
           MaxCallLayers -> 8
                 Timeout -> 3600000
     MaxModuelCallLayers -> 256
               EntryTask -> Main
      ModRepoUsernameRef -> 
      ModRepoPasswordRef -> 
    work dir: /up_project/up/tests/modtests/0004
    -exec task: Main
    loading [Task]:  ./up.yml
    module: [self], instance id: [dev], exec profile: []
    Task1: [Main ==> Main: main entry ]
    -Step1:
    =Task2: [Main ==> internal_task:  ]
    --Step1:
    ~~SubStep1: [print:  ]
    this is a internal task in caller
    --Step2:
    cmd( 1):
    -
    total 12
    -rw-r--r--    1 root     root           253 Jun 11 09:38 upconfig.yml
    -rw-r--r--    1 root     root           521 Jun 11 09:38 up.yml
    drwxr-xr-x    3 root     root            96 Jun 11 09:38 hello-module
    -rw-r--r--    1 root     root          1019 Jun 11 09:38 doc.yml
    drwxr-xr-x    6 root     root           192 Jun 11 09:38 .
    drwxr-xr-x   19 root     root           608 Oct  1 21:59 ..
    
    -
     .. ok
    cmd( 2):
    -
    up.yml
    upconfig.yml
    
    -
     .. ok
    cmd( 3):
    -
    /up_project/up/tests/modtests/0004
    
    -
     .. ok
    cmd( 4):
    -
    modtests
    
    -
     .. ok
    . ok
    -Step2:
     WARN: [config file does not exist] - [use builtin defaults]
    loading [Task]:  ./up.yml
    module: [hello-module], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [hello-module] task: [Say_world]
    Task1: [TODO: Main Caller Taskname ==> Say_world:  ]
    -Step1:
    cmd( 1):
    -
    total 4
    -rw-r--r--    1 root     root           796 Jun 11 09:38 up.yml
    drwxr-xr-x    6 root     root           192 Jun 11 09:38 ..
    drwxr-xr-x    3 root     root            96 Jun 11 09:38 .
    
    -
     .. ok
    cmd( 2):
    -
    up.yml
    
    -
     .. ok
    cmd( 3):
    -
    /up_project/up/tests/modtests/0004/hello-module
    
    -
     .. ok
    cmd( 4):
    -
    modtests
    
    -
     .. ok
    . ok
    -Step2: [
    this should call its own internal task
    ]
    =Task3: [TODO: Main Caller Taskname/Say_world ==> internal_task:  ]
    --Step1:
    ~~SubStep1: [print:  ]
    this is a internal task in module
    --Step2:
    cmd( 1):
    -
    total 4
    -rw-r--r--    1 root     root           796 Jun 11 09:38 up.yml
    drwxr-xr-x    6 root     root           192 Jun 11 09:38 ..
    drwxr-xr-x    3 root     root            96 Jun 11 09:38 .
    
    -
     .. ok
    cmd( 2):
    -
    up.yml
    
    -
     .. ok
    cmd( 3):
    -
    /up_project/up/tests/modtests/0004/hello-module
    
    -
     .. ok
    cmd( 4):
    -
    modtests
    
    -
     .. ok
    . ok
    -Step3:
    =Task2: [Main ==> internal_task:  ]
    --Step1:
    ~~SubStep1: [print:  ]
    this is a internal task in caller
    --Step2:
    cmd( 1):
    -
    total 12
    -rw-r--r--    1 root     root           253 Jun 11 09:38 upconfig.yml
    -rw-r--r--    1 root     root           521 Jun 11 09:38 up.yml
    drwxr-xr-x    3 root     root            96 Jun 11 09:38 hello-module
    -rw-r--r--    1 root     root          1019 Jun 11 09:38 doc.yml
    drwxr-xr-x    6 root     root           192 Jun 11 09:38 .
    drwxr-xr-x   19 root     root           608 Oct  1 21:59 ..
    
    -
     .. ok
    cmd( 2):
    -
    up.yml
    upconfig.yml
    
    -
     .. ok
    cmd( 3):
    -
    /up_project/up/tests/modtests/0004
    
    -
     .. ok
    cmd( 4):
    -
    modtests
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level