This repository has been archived on 2025-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
linux-bash-scripts/gitea/auto_mapper/README.md

71 lines
5.2 KiB
Markdown

# Gitea Teams auto mapping
## Description
This script will copy / update all teams (excluding `Owners`) from a specified source organization to all other organizations (except for excluded ones). It can be used to achieve a more controllable permissions hierarchy within Gitea, similar to sub-groups as being available in Gitlab.
## Author(s)
- [Enrico Ludwig](https://git.zion-networks.de/eludwig) <[enrico.ludwig@zion-networks.de](mailto:enrico.ludwig@zion-networks.de?subject=Gitlab%20to%20Gitea%20migration%20script)>
## License
MIT License. For more details, refer to the [LICENSE](https://git.zion-networks.de/ZionNetworks/linux-bash-scripts/src/branch/main/LICENSE) file.
## Usage
```sh
pip install -r requirements.txt
python3 auto_mapper.py [options]
```
## Available script arguments
| Argument | Type | Description | Valid values |
| --------------- | --------------- | ----------------------------------------------- | ----------------------------------------------------------------- |
| `--host` | Key-Value | Specify the Gitea instance host | An IP address or hostname |
| `--port` | Key-Value | Specify the Gitea instance port | A valid port from 1 to 65535 |
| `--token` | Key-Value | Specify the Gitea instance token | A valid Gitea user token string |
| `--ssl` | Switch | Specify if the Gitea instance uses SSL | Enable SSL support (https) |
| `--debug` | Switch | Enable debug logging | Enable debug output |
| `--source-orga` | Key-Value | Specify the source organization | The name of the source organization |
| `--dry-run` | Switch | Enable dry-run mode, no changes will be made | Enable dry-run mode to prevent changes |
| `--exclude` | Multi Key-Value | Specify organizations to exclude | Can be used multiple times to exclude specific organizations |
| `--update` | Switch | Updates existing teams in target organizations | Enable to update already existing teams at target organizations |
| `--override` | Switch | Override existing teams in target organizations | Enable to override already existing teams at target organizations |
## Using environment variables
Note: Instead of using environment variables you can also make use of an `.env` file, which contains the respective environment variables.
| Argument | Type | Description | Valid values |
| ---------------- | --------------- | ----------------------------------------------- | ----------------------------------------------------------------- |
| `GITEA_INSTANCE` | Key-Value | Specify the Gitea instance host | An IP address or hostname |
| `GITEA_PORT` | Key-Value | Specify the Gitea instance port | A valid port from 1 to 65535 |
| `GITEA_TOKEN` | Key-Value | Specify the Gitea instance token | A valid Gitea user token string |
| `GITEA_SSL` | Switch | Specify if the Gitea instance uses SSL | Enable SSL support (https) |
| `DEBUG` | Switch | Enable debug logging | Enable debug output |
| `SOURCE_ORGA` | Key-Value | Specify the source organization | The name of the source organization |
| `DRY_RUN` | Switch | Enable dry-run mode, no changes will be made | Enable dry-run mode to prevent changes |
| `EXCLUDE_ORGAS` | Multi Key-Value | Specify organizations to exclude | Can be used multiple times to exclude specific organizations |
| `UPDATE_TEAMS` | Switch | Updates existing teams in target organizations | Enable to update already existing teams at target organizations |
| `OVERRIDE_TEAMS` | Switch | Override existing teams in target organizations | Enable to override already existing teams at target organizations |
## Using Dockerfile
**With .env file**
`docker run --rm -it $(docker build -q .)`
**With environment variables**
`docker run --rm -it -eGITEA_INSTANCE=localhost -eGITEA_PORT=3000 $(docker build -q .)`
Use `-e` arguments as shown in the example above for setting environment variables.
## Example
```sh
python3 auto_mapper.py \
--host "127.0.0.1" \
--port 3000 \
--token "your-secret-user-token" \
--source-orga "MyTemplateOrga"
```
For any issues, please refer to the contact details provided in the author's contact information section.