#1658 Wrapper to check / create projects on GitLab using the REST API
Opened 2 months ago by gwmngilfen. Modified 4 days ago

Pagure-exporter will be doing the heavy lifting of the migration, but (AIUI) it assumes the target repo exists on GitLab

We should write a script to query the GitLab API for a list of repos (derived from Pagure) and create them as required.


Metadata Update from @gwmngilfen:
- Issue marked as blocking: #1654

2 months ago

Current plan is to start with an external script to deal with creating the GitLab repo, then to see if it can be integrated into Pagure Exporter. Target https://github.com/fedora-infra/pagure-exporter/tree/fogo branch for any exporter changes

OK, so I've written https://gitlab.com/gwmngilfen/create_project as a starting point:

  • Trivial wrapper that uses a config file for base URL, namespace, and API key so they can be re-used
  • Project name is a cmdline arg so we can loop over it easily
  • It uses python-gitlab so it could be integrated into pagure-exporter if needed

Tested locally on my GitLab namespace:

base_url: https://gitlab.com
namespace: gwmngilfen
gl_key: REDACTED
debug: false
(.venv) [greg@topaz]$ ./create_project.py create_project
Target project: gwmngilfen/create_project
Success: Project gwmngilfen/create_project already exists.
(.venv) [greg@topaz]$ ./create_project.py create_project2
Target project: gwmngilfen/create_project2
Project gwmngilfen/create_project2 does not exist. Creating...
Success: Project created: https://gitlab.com/gwmngilfen/create_project2

@arrfab @t0xic0der I think this will get us started? We can extend for nested namespaces or integrate into pagure-export if needed, ofc

Log in to comment on this ticket.

Metadata