From 1e3cf595bcd309d5bf63c805500f1d90fba45b86 Mon Sep 17 00:00:00 2001 From: Enrico Ludwig Date: Tue, 6 Aug 2024 21:40:50 +0200 Subject: [PATCH] Updated README and added DEBUG argument to auto_mapper --- gitea/auto_mapper/README.md | 33 ++++++++++++++++++++++++++++++-- gitea/auto_mapper/auto_mapper.py | 2 ++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gitea/auto_mapper/README.md b/gitea/auto_mapper/README.md index 3d6c953..5282ec2 100644 --- a/gitea/auto_mapper/README.md +++ b/gitea/auto_mapper/README.md @@ -22,14 +22,43 @@ python3 auto_mapper.py [options] | `--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 | -| `--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) | | `--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 \ diff --git a/gitea/auto_mapper/auto_mapper.py b/gitea/auto_mapper/auto_mapper.py index d69c7d8..9298fcf 100644 --- a/gitea/auto_mapper/auto_mapper.py +++ b/gitea/auto_mapper/auto_mapper.py @@ -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_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 +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 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 @@ -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_TOKEN : str = args.token if args.token else GITEA_TOKEN 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 DRY_RUN : bool = args.dry_run if args.dry_run else DRY_RUN EXCLUDE_ORGAS : list = args.exclude if args.exclude else EXCLUDE_ORGAS