Prototypes built

In order to be able to better understand what both the Pagure and GitLab APIs are capable of and how they would be able to be of assistance in helping us move assets from the source namespace to the destination namespace, we created a prototype tool called “protop2g”.

First rendition

The initial version of protop2g was hacked together in around a couple of days using libraries like Requests, Asciimatics <https://asciimatics.readthedocs.io/en/stable/intro.html> etc. to build an interactive text-based user interface.

The following is a screenshot of the TUI screen where the users are given the option to enter their source namespace location, API key for accessing the source namespace location, destination namespace location, API key for accessing the destination namespace location.

../_images/tui-protop2g-main.png

The following is a screenshot of the TUI screen where the users are shown the metadata of both the source namespace and destination namespace. They are also given the option to pick which assets they wish to interact with and transfer, like repository data, issue tickets etc.

../_images/tui-protop2g-repo.png

Unfortunately, this approach was scrapped due to the following reasons :-

  • The TUI application approach would not allow for a simpler automation to help folks who either own and/or maintain a lot of repositories.

  • The logic for building the screens and sharing information around the screens could possibly deviate from the actual feasibility checks.

  • The colour palette and the elements used in the TUI might not be accessible on a variety of terminal and console setups, that people have.

Second rendition

After the initial version was archived in a different branch, the next version of protop2g was created using libraries like Requests, Click, GitPython etc. to better facilitate an interactive command-line interface.

The following is a console snippet of the help documentation of the overall usage of the protop2g application.

(venv) [t0xic0der@fedorable protop2g]$ protop2g -g xxxxxxxxxxxxxxxxxx -p xxxxxxxxxxxxxxxxxx -s mdapi -d 42823949 -f t0xic0der -t t0xic0der repo --help
Usage: protop2g [OPTIONS] COMMAND [ARGS]...

Options:
  -s, --srce TEXT  Source namespace for importing assets from  [required]
  -d, --dest TEXT  Destination namespace for exporting assets to  [required]
  -p, --pkey TEXT  Pagure API key for accessing the source namespace
                   [required]
  -g, --gkey TEXT  GitLab API key for accessing the destination namespace
                   [required]
  -f, --fusr TEXT  Username of the account that owns the Pagure API key
                   [required]
  -t, --tusr TEXT  Username of the account that owns the GitLab API key
                   [required]
  --version        Show the version and exit.
  --help           Show this message and exit.

Commands:
  repo  Initialize transfer of repository assets
  tkts  Initiate transfer of issue tickets

The following is a console snippet of the help documentation for the “repo” command of the protop2g application.

The options for the command allow for people to be able to choose the branches that should be transferred.

(venv) [t0xic0der@fedorable protop2g]$ protop2g -g xxxxxxxxxxxxxxxxxx -p xxxxxxxxxxxxxxxxxx -s mdapi -d 42823949 -f t0xic0der -t t0xic0der repo --help
Usage: protop2g repo [OPTIONS]

  Initialize transfer of repository assets

Options:
  -b, --brcs TEXT  List of branches to extract
  --help           Show this message and exit.

The following is a console snippet of the help documentation for the “tkts” command of the protop2g application.

The options for the command allow for people to be able to choose the nature of issues they want to transfer.

(venv) [t0xic0der@fedorable protop2g]$ protop2g -g xxxxxxxxxxxxxxxxxx -p xxxxxxxxxxxxxxxxxx -s mdapi -d 42823949 -f t0xic0der -t t0xic0der tkts --help
Usage: protop2g tkts [OPTIONS]

  Initiate transfer of issue tickets

Options:
  -o, --open  Extract only the open issue tickets
  -c, --shut  Extract only the closed issue tickets
  -a, --full  Extract all the issue tickets
  --help      Show this message and exit.

The following is a console snippet of the protop2g application at work, where it is transferring the repository assets of all the branches from the source namespace to the destination namespace.

(venv) [t0xic0der@fedorable protop2g]$ protop2g -g xxxxxxxxxxxxxxxxxx -p xxxxxxxxxxxxxxxxxx -s mdapi -d 42823949 -f t0xic0der -t t0xic0der repo
[ BUSY ] Requesting for source namespace metadata...
[ PASS ] Source namespace metadata acquisition succeeded!
         Name: mdapi
         Identifier: 221
         Maintainer: Pierre-YvesChibon (ID pingou)
         Location: https://pagure.io/mdapi
         Address: https://t0xic0der:xxxxxxxxxxxxxxxxxx@pagure.io/mdapi.git
         Created on: Thu Oct 22 16:33:58 2015
         Last modified on: Thu Oct 22 16:33:58 2015
         Tags: ['fedmsg', 'fedora-infra']
[ BUSY ] Requesting for destination namespace metadata...
[ PASS ] Destination namespace metadata acquisition succeeded!
         Name: t0xic0der/protop2g-test
         Identifier: 42823949
         Maintainer: Akashdeep Dhar (ID t0xic0der)
         Location: https://gitlab.com/t0xic0der/protop2g-test
         Address: https://t0xic0der:xxxxxxxxxxxxxxxxxx@gitlab.com/t0xic0der/protop2g-test.git
         Created on: 2023-01-23T16:18:30.217Z
         Last modified on: 2023-01-28T18:44:14.075Z
         Tags: []
[ BUSY ] Attempting source namespace assets clone...
[ PASS ] Source namespace assets clone succeeded!
         Directory: /var/tmp/protop2g-tempsrce-a63xrvkc
         Time taken: 6.77 second(s)
[ BUSY ] Attempting destination namespace assets clone...
[ PASS ] Destination namespace assets clone succeeded!
         Directory: /var/tmp/protop2g-tempdest-w6_kxcbz
         Time taken: 2.36 second(s)
[ BUSY ] Reading branches data from the locally cloned assets...
[ PASS ] Branches data reading succeeded!
         Available in source namespace: 4 branch(es)
           - (SRCE branch) HEAD
           - (SRCE branch) master
           - (SRCE branch) production
           - (SRCE branch) staging
         Available in destination namespace: 5 branch(es)
           - (DEST branch) HEAD
           - (DEST branch) main
           - (DEST branch) master
           - (DEST branch) production
           - (DEST branch) staging
         Requested for transferring: 0 branch(es)
[ BUSY ] Initializing namespace assets transfer...
[ WARN ] Transferring 4 available branches
         [1/4] Branch 'HEAD' was transferred to the destination namespace
         [2/4] Branch 'master' was transferred to the destination namespace
         [3/4] Branch 'production' was transferred to the destination namespace
         [4/4] Branch 'staging' was transferred to the destination namespace
         Assets transferred: 4 branch(es) completed, 4 branch(es) requested
         Time taken: 4.99 second(s)
[ PASS ] Namespace assets transfer succeeded!

Resources

The project can be found over here.