Updated README and added DEBUG argument to auto_mapper

This commit is contained in:
Enrico Ludwig 2024-08-06 21:40:50 +02:00
parent 24d6c3008f
commit 1e3cf595bc
2 changed files with 33 additions and 2 deletions

View File

@ -22,14 +22,43 @@ python3 auto_mapper.py [options]
| `--host` | Key-Value | Specify the Gitea instance host | An IP address or hostname | | `--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 | | `--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 | | `--token` | Key-Value | Specify the Gitea instance token | A valid Gitea user token string |
| `--source-orga` | Key-Value | Specify the source organization | The name of the source organization |
| `--exclude` | Multi Key-Value | Specify organizations to exclude | Can be used multiple times to exclude specific organizations |
| `--ssl` | Switch | Specify if the Gitea instance uses SSL | Enable SSL support (https) | | `--ssl` | Switch | Specify if the Gitea instance uses SSL | Enable SSL support (https) |
| `--debug` | Switch | Enable debug logging | Enable debug output | | `--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 | | `--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 | | `--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 | | `--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 ## Example
```sh ```sh
python3 auto_mapper.py \ python3 auto_mapper.py \

View File

@ -18,6 +18,7 @@ GITEA_INSTANCE : str = os.getenv("GITEA_INSTANCE") if os.getenv
GITEA_PORT : int = os.getenv("GITEA_PORT") if os.getenv("GITEA_PORT") != None else None GITEA_PORT : int = os.getenv("GITEA_PORT") if os.getenv("GITEA_PORT") != None else None
GITEA_TOKEN : str = os.getenv("GITEA_TOKEN") if os.getenv("GITEA_TOKEN") != None else None GITEA_TOKEN : str = os.getenv("GITEA_TOKEN") if os.getenv("GITEA_TOKEN") != None else None
GITEA_SSL : bool = str_to_bool(os.getenv("GITEA_SSL")) if os.getenv("GITEA_SSL") != None else False GITEA_SSL : bool = str_to_bool(os.getenv("GITEA_SSL")) if os.getenv("GITEA_SSL") != None else False
DEBUG : bool = str_to_bool(os.getenv("DEBUG")) if os.getenv("DEBUG") != None else False
SOURCE_ORGA : str = os.getenv("SOURCE_ORGA") if os.getenv("SOURCE_ORGA") != None else None SOURCE_ORGA : str = os.getenv("SOURCE_ORGA") if os.getenv("SOURCE_ORGA") != None else None
DRY_RUN : bool = str_to_bool(os.getenv("DRY_RUN")) if os.getenv("DRY_RUN") != None else None DRY_RUN : bool = str_to_bool(os.getenv("DRY_RUN")) if os.getenv("DRY_RUN") != None else None
EXCLUDE_ORGAS : list = os.getenv("EXCLUDE_ORGAS").split(',') if os.getenv("EXCLUDE_ORGAS") != None else None EXCLUDE_ORGAS : list = os.getenv("EXCLUDE_ORGAS").split(',') if os.getenv("EXCLUDE_ORGAS") != None else None
@ -41,6 +42,7 @@ GITEA_INSTANCE : str = args.host if args.host else GITEA_I
GITEA_PORT : int = args.port if args.port else GITEA_PORT GITEA_PORT : int = args.port if args.port else GITEA_PORT
GITEA_TOKEN : str = args.token if args.token else GITEA_TOKEN GITEA_TOKEN : str = args.token if args.token else GITEA_TOKEN
GITEA_SSL : bool = args.ssl if args.ssl else GITEA_SSL GITEA_SSL : bool = args.ssl if args.ssl else GITEA_SSL
DEBUG : bool = args.debug if args.debug else DEBUG
SOURCE_ORGA : str = args.source_orga if args.source_orga else SOURCE_ORGA SOURCE_ORGA : str = args.source_orga if args.source_orga else SOURCE_ORGA
DRY_RUN : bool = args.dry_run if args.dry_run else DRY_RUN DRY_RUN : bool = args.dry_run if args.dry_run else DRY_RUN
EXCLUDE_ORGAS : list = args.exclude if args.exclude else EXCLUDE_ORGAS EXCLUDE_ORGAS : list = args.exclude if args.exclude else EXCLUDE_ORGAS