61 lines
1.6 KiB
Markdown
61 lines
1.6 KiB
Markdown
# GitLib
|
|
|
|
The `gitapi.py` is an API for OgGit, written in Python/Flask.
|
|
|
|
It is an HTTP server that receives commands and executes maintenance actions including the creation and deletion of repositories.
|
|
|
|
|
|
# Installing Python dependencies
|
|
|
|
The conversion of the code to Python 3 currently requires the packages specified in `requirements.txt`.
|
|
|
|
To install Python dependencies, the `venv` module is used (https://docs.python.org/3/library/venv.html), which installs all dependencies in an environment independent of the system.
|
|
|
|
|
|
# Usage
|
|
|
|
|
|
# Ubuntu 24.04
|
|
|
|
sudo apt install -y python3-flask python3-paramiko opengnsys-flask-executor opengnsys-flask-restx
|
|
|
|
The `opengnsys-flask-executor` and `opengnsys-flask-restx` packages are available on the OpenGnsys package server.
|
|
|
|
Run with:
|
|
|
|
./gitapi.py
|
|
|
|
**Note:** Run as `opengnsys`, as it manages the images located in `/opt/opengnsys/images`.
|
|
|
|
|
|
# Documentation
|
|
|
|
Python documentation can be generated using a utility like pdoc3 (there are multiple possible alternatives):
|
|
|
|
# Install pdoc3
|
|
pip install --user pdoc3
|
|
|
|
# Generate documentation
|
|
pdoc3 --force --html opengnsys_git_installer.py
|
|
|
|
# Operation
|
|
|
|
## Requirements
|
|
|
|
The gitapi is designed to run within an existing opengnsys environment. It should be installed in an ogrepository.
|
|
|
|
|
|
## API Examples
|
|
|
|
### Get list of branches
|
|
|
|
$ curl -L http://localhost:5000/repositories/linux/branches
|
|
{
|
|
"branches": [
|
|
"master"
|
|
]
|
|
}
|
|
|
|
### Synchronize with remote repository
|
|
|
|
curl --header "Content-Type: application/json" --data '{"remote_repository":"foobar"}' -X POST -L http://localhost:5000/repositories/linux/sync |