module multi vesioning

Showcase how to manage multiple versions of same module in its version directories

source

Use version git repo as module directory

If the module is code in git repo, the other way to organize the module and version is to checkout each version of that module and put it into a module directory - .modules, like below:

myproject
├── hello-module
│   ├── up.yml
│   └── upconfig.yml
│   └── upconfig.yml
├── .modules
│      ├── hi-module@release_1.2.3
│      └── up.yml
│      ├── hi-module@feature_branch
│      └── up.yml
│      ├── hi-module@e8e9dc5dc913e211fdaa3bf1bd8a6618e602e8ff
│      └── up.yml
│      ├── hi-module@e8e9dc5
│      └── up.yml
├───── world-module
│      ├── up.yml
│      └── upconfig.yml
├───── up.yml
└───── upconfig.yml

module pull

Ξ ▶ mod pull -d ./tests/modtests/0011 -i dev --configdir=$./tests/modtests/ -w refdir
loading [Config]:  ./tests/modtests/0011/upconfig.yml
Main config:
  Version -> 1.0.0
  RefDir -> ./tests/modtests/0011
  WorkDir -> refdir
  TaskFile -> up.yml
  Verbose -> vvv
  ModuleName -> reverent_archimedes3
  MaxCallLayers -> 8
work dir: ./tests/modtests/0011
loading [Task]:  ./up.yml
module: [reverent_archimedes3] instance id: [dev]
-validate all modules:
-pull repos:
  +------------+-------------------------------------------+
  |  PROPERTY  |                   VALUE                   |
  +------------+-------------------------------------------+
  | alias      | hello                                     |
  | dir        | .upmodules/hello@v2                       |
  | repo       | https://github.com/upcmd/hello-module.git |
  | version    | v2                                        |
  | pullpolicy | skip                                      |
  | instanceid | nonamed                                   |
  | subdir     |                                           |
  +------------+-------------------------------------------+
WARN: [module repo exist: skipped] - [repo: [.upmodules/hello@v2]]
  checkout version
checkout version: v2 ...
  git checkout v2
  Already on 'v2'
  Your branch is up to date with 'origin/v2'.
  +------------+-------------------------------------------+
  |  PROPERTY  |                   VALUE                   |
  +------------+-------------------------------------------+
  | alias      | hello-dummy1                              |
  | dir        | .upmodules/hello-dummy1@master            |
  | repo       | https://github.com/upcmd/hello-module.git |
  | version    | master                                    |
  | pullpolicy | always                                    |
  | instanceid | nonamed                                   |
  | subdir     |                                           |
  +------------+-------------------------------------------+
removing .upmodules/hello-dummy1@master ...Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Compressing objects: 100% (4/4), done.
  Total 9 (delta 2), reused 9 (delta 2), pack-reused 0
  checkout version
checkout version: master ...
  git checkout master
  Already on 'master'
  Your branch is up to date with 'origin/master'.
  +------------+------------------------------------------------------------------+
  |  PROPERTY  |                              VALUE                               |
  +------------+------------------------------------------------------------------+
  | alias      | hello-dummy2                                                     |
  | dir        | .upmodules/hello-dummy2@25456bbcd17db524d1148e42bdcc3bb36ce90042 |
  | repo       | https://github.com/upcmd/hello-module.git                        |
  | version    | 25456bbcd17db524d1148e42bdcc3bb36ce90042                         |
  | pullpolicy | always                                                           |
  | instanceid | nonamed                                                          |
  | subdir     |                                                                  |
  +------------+------------------------------------------------------------------+
removing .upmodules/hello-dummy2@25456bbcd17db524d1148e42bdcc3bb36ce90042 ...Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Compressing objects: 100% (4/4), done.
  Total 9 (delta 2), reused 9 (delta 2), pack-reused 0
  checkout version
checkout version: 25456bbcd17db524d1148e42bdcc3bb36ce90042 ...
  git checkout 25456bbcd17db524d1148e42bdcc3bb36ce90042
Note: switching to '25456bbcd17db524d1148e42bdcc3bb36ce90042'.

module list

Ξ ▶  mod list -d ./tests/modtests/0011 -i dev --configdir=./tests/modtests/0011 -w refdir
loading [Config]:  ./tests/modtests/0011/upconfig.yml
Main config:
  Version -> 1.0.0
  RefDir -> ./tests/modtests/0011
  WorkDir -> refdir
  TaskFile -> up.yml
  Verbose -> vvv
  ModuleName -> elated_payne9
  MaxCallLayers -> 8
work dir: ./tests/modtests/0011
loading [Task]:  ./up.yml
module: [elated_payne9] instance id: [dev]
-list all modules:
  +-----+--------------+------------------------------------------------------------------+-------------------------------------------+------------------------------------------+------------+------------+--------+
  | IDX |    ALIAS     |                               DIR                                |                   REPO                    |                 VERSION                  | PULLPOLICY | INSTANCEID | SUBDIR |
  +-----+--------------+------------------------------------------------------------------+-------------------------------------------+------------------------------------------+------------+------------+--------+
  |   1 | hello-module | hello-module/                                                    |                                           |                                          |            | nonamed    |        |
  |   2 | hello        | .upmodules/hello@v2                                              | https://github.com/upcmd/hello-module.git | v2                                       | skip       | nonamed    |        |
  |   3 | hello-dummy1 | .upmodules/hello-dummy1@master                                   | https://github.com/upcmd/hello-module.git | master                                   | always     | nonamed    |        |
  |   4 | hello-dummy2 | .upmodules/hello-dummy2@25456bbcd17db524d1148e42bdcc3bb36ce90042 | https://github.com/upcmd/hello-module.git | 25456bbcd17db524d1148e42bdcc3bb36ce90042 | always     | nonamed    |        |
  +-----+--------------+------------------------------------------------------------------+-------------------------------------------+------------------------------------------+------------+------------+--------+
-validate all modules:

config file - upconfig.yml

    
    version: 1.0.0
    Verbose: vvv
    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
    
      - repo: https://github.com/upcmd/hello-module.git
        alias: hello
        #v2 is a branch
        version: v2
        pullpolicy: skip
    
      - repo: https://github.com/upcmd/hello-module.git
        alias: hello-dummy1
        version: master
        pullpolicy: always
    
      - repo: https://github.com/upcmd/hello-module.git
        alias: hello-dummy2
        #    version: e8e9dc5
        version: 25456bbcd17db524d1148e42bdcc3bb36ce90042
        pullpolicy: always
    

up task - up.yml

    tasks:
      -
        name: Main
        desc: main entry
        task:
          -
            func: call
            do: hello-module.Say_hello
    
          -
            func: call
            do: hello.Say_hello
    
          -
            func: call
            do: hello.Say_hello
    
          -
            func: call
            do: hello-dummy1.Say_world
    
          -
            func: call
            do: hello-dummy2.Say_hello
    
    

up module task - up.yml

    
    tasks:
      -
        name: Main
        desc: main entry
        task:
          -
            func: shell
            desc: main job
            do:
              - echo "hello "
      -
        name: Say_hello
        task:
          -
            func: cmd
            vars:
              a: aaa
            do:
              - name: print
                cmd: "... hello"
    
          -
            func: call
            do: hi-module.Say_hi
    
    

up module config - upconfig.yml

    RefDir: .
    TaskFile: up.yml
    
    Modules:
      -
        dir: hi-module/
        alias: hi-module
    
    

hi module task - up.yml

    
    tasks:
      -
        name: Main
        desc: main entry
        task:
          -
            func: shell
            desc: main job
            do:
              - echo "hello "
    
      -
        name: Say_hi
        task:
          -
            func: cmd
            vars:
              a: aaa
            do:
              - name: print
                cmd: "... hi"
    
    
Main log file
    loading [Config]:  ./tests/modtests/0011/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/modtests/0011
                 WorkDir -> refdir
              AbsWorkDir -> /up_project/up/tests/modtests/0011
                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/0011
    -exec task: Main
    loading [Task]:  ./up.yml
    module: [self], instance id: [dev], exec profile: []
    Task1: [Main ==> Main: main entry ]
    -Step1:
    loading [Config]:  ./upconfig.yml
    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_hello]
    Task2: [TODO: Main Caller Taskname ==> Say_hello:  ]
    -Step1:
    ~SubStep1: [print:  ]
    ... hello
    -Step2:
     WARN: [config file does not exist] - [use builtin defaults]
    loading [Task]:  ./up.yml
    module: [hi-module], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [hi-module] task: [Say_hi]
    Task2: [TODO: Main Caller Taskname ==> Say_hi:  ]
    -Step1:
    ~SubStep1: [print:  ]
    ... hi
    -Step2:
     WARN: [config file does not exist] - [use builtin defaults]
    loading [Task]:  ./up.yml
    module: [hello], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [hello] task: [Say_hello]
    Task3: [TODO: Main Caller Taskname ==> Say_hello:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... hello from Say_hello
    -Step3:
     WARN: [config file does not exist] - [use builtin defaults]
    loading [Task]:  ./up.yml
    module: [hello], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [hello] task: [Say_hello]
    Task3: [TODO: Main Caller Taskname ==> Say_hello:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... hello from Say_hello
    -Step4:
     WARN: [config file does not exist] - [use builtin defaults]
    loading [Task]:  ./up.yml
    module: [hello-dummy1], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [hello-dummy1] task: [Say_world]
    Task2: [TODO: Main Caller Taskname ==> Say_world:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... world from Say_world
    -Step5:
     WARN: [config file does not exist] - [use builtin defaults]
    loading [Task]:  ./up.yml
    module: [hello-dummy2], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [hello-dummy2] task: [Say_hello]
    Task3: [TODO: Main Caller Taskname ==> Say_hello:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... hello from Say_hello
    
Logs with different verbose level
Raw logs with different verbose level