Skip to main content

Gateway Abstraction Layer - Provider-agnostic API Gateway configuration system

Project description

Gateway Abstraction Layer (GAL) - Python Edition

Tests Docker Build PyPI version Python Version License Downloads

Gateway-Abstraktionsschicht - Provider-agnostisches API-Gateway-Konfigurations- und Transformationssystem in Python.

Definiere deine API-Gateway-Konfiguration einmal und deploye sie auf Envoy, Kong, APISIX, Traefik oder anderen Gateways - ohne Vendor Lock-in.

Features

  • Einheitliche YAML-Konfiguration für mehrere API-Gateway-Provider
  • Unterstützung für Envoy, Kong, APISIX, Traefik
  • Automatische Payload-Transformationsgenerierung
  • REST- und gRPC-Service-Unterstützung (3 gRPC + 2 REST Services)
  • Default-Wert-Injektion
  • Berechnete Felder (UUIDs, Zeitstempel)
  • Feldvalidierung
  • Strukturiertes Logging mit konfigurierbaren Log-Levels
  • Reines Python - kein Go erforderlich!
  • CI/CD Ready - GitHub Actions Workflows integriert
  • Umfassende Tests - 101 Tests mit 89% Coverage

Installation

🐳 Docker (Empfohlen)

Von GitHub Container Registry (Fertig)

# Latest Version ziehen
docker pull ghcr.io/pt9912/x-gal:latest

# Direkt verwenden
docker run --rm ghcr.io/pt9912/x-gal:latest list-providers

# Mit Volume für Ausgabe
docker run --rm -v $(pwd)/generated:/app/generated \
  ghcr.io/pt9912/x-gal:latest \
  generate --config examples/gateway-config.yaml --provider envoy --output generated/envoy.yaml

# Spezifische Version
docker pull ghcr.io/pt9912/x-gal:v1.0.0

Lokal bauen

# Image bauen
docker build -t gal:latest .

# Verwenden
docker run --rm gal:latest list-providers

🐍 Python (Lokal)

# Repository klonen
git clone https://github.com/pt9912/x-gal.git
cd x-gal

# Virtuelle Umgebung erstellen
python3 -m venv venv
source venv/bin/activate  # Unter Windows: venv\Scripts\activate

# Abhängigkeiten installieren
pip install -e .         # Runtime dependencies
pip install -e .[dev]    # Mit Dev-Tools (pytest, black, flake8, isort)

# CLI ausführbar machen
chmod +x gal-cli.py

📦 PyPI (Empfohlen für Produktion)

# Stabile Version von PyPI installieren
pip install gal-gateway

# CLI verwenden
gal --help
gal --version

# Mit Development Tools
pip install gal-gateway[dev]

# Spezifische Version
pip install gal-gateway==1.0.0

# Pre-Release von TestPyPI (optional)
pip install --index-url https://test.pypi.org/simple/ \
            --extra-index-url https://pypi.org/simple/ \
            gal-gateway

PyPI Links:

Schnellstart

🐳 Mit Docker

# Alle Provider generieren
docker run --rm -v $(pwd)/generated:/app/generated gal:latest \
  generate-all --config examples/gateway-config.yaml --output-dir generated

# Einzelnen Provider generieren
docker run --rm -v $(pwd)/generated:/app/generated gal:latest \
  generate --config examples/gateway-config.yaml --provider kong --output generated/kong.yaml

# Mit Docker Compose
docker-compose up gal-generate  # Generiert Envoy-Konfiguration
PROVIDER=kong docker-compose up gal-generate  # Generiert Kong-Konfiguration

🐍 Mit Python

# Envoy-Konfiguration generieren
python gal-cli.py generate --config examples/gateway-config.yaml --provider envoy --output generated/envoy.yaml

# Oder das Convenience-Script verwenden
./generate-envoy.sh

# Für alle Provider generieren
python gal-cli.py generate-all --config examples/gateway-config.yaml

Konfigurationsbeispiel

Das Beispiel enthält:

  • 3 gRPC Services: user_service, order_service, notification_service
  • 2 REST Services: product_service, payment_service

Jeder mit Transformationsregeln für:

  • Standard-Werte
  • Berechnete Felder (UUID, Zeitstempel-Generierung)
  • Feldvalidierung

Unterstützte Provider

Provider Status Features
Envoy Vollständige Unterstützung mit Wasm/Lua
Kong Lua Plugins
APISIX Lua Scripts
Traefik Middleware

Projektstruktur

x-gal/
├── gal/
│   ├── __init__.py
│   ├── config.py              # Konfigurationsmodelle
│   ├── manager.py             # Haupt-Orchestrator
│   ├── provider.py            # Provider-Interface
│   ├── providers/
│   │   ├── __init__.py
│   │   ├── envoy.py
│   │   ├── kong.py
│   │   ├── apisix.py
│   │   └── traefik.py
│   └── transformation/
│       ├── __init__.py
│       ├── engine.py
│       └── generators.py
├── gal-cli.py                 # CLI-Tool
├── examples/
│   └── gateway-config.yaml
├── tests/
└── docs/

CLI-Befehle

# Konfiguration generieren
python gal-cli.py generate --config CONFIG --provider PROVIDER --output FILE

# Konfiguration validieren
python gal-cli.py validate --config CONFIG

# Für alle Provider generieren
python gal-cli.py generate-all --config CONFIG --output-dir OUTPUT

# Konfigurationsinformationen anzeigen
python gal-cli.py info --config CONFIG

# Verfügbare Provider auflisten
python gal-cli.py list-providers

# Mit Logging (für Debugging)
python gal-cli.py --log-level debug generate --config CONFIG --provider envoy

# Log Levels: debug, info, warning (default), error
python gal-cli.py --log-level info generate-all --config CONFIG

Logging-Optionen

GAL unterstützt strukturiertes Logging mit verschiedenen Verbosity-Levels:

  • --log-level debug: Detaillierte Debug-Informationen (Parsing, Validierung, Generation)
  • --log-level info: Haupt-Operationen und Zusammenfassungen
  • --log-level warning: Warnungen und nicht-kritische Probleme (Standard)
  • --log-level error: Nur kritische Fehler

Beispiel:

# Debugging aktivieren
docker run --rm ghcr.io/pt9912/x-gal:latest \
  --log-level debug \
  generate --config examples/gateway-config.yaml --provider envoy

🐳 Docker Deployment

Image bauen

# Standard-Build
docker build -t gal:latest .

# Mit spezifischer Version
docker build -t gal:1.0.0 .

Docker Compose Services

# Standard CLI (interaktiv)
docker-compose up gal

# Development mit Live-Reload
docker-compose --profile dev up gal-dev

# Konfiguration generieren
docker-compose --profile generate up gal-generate

# Konfiguration validieren
CONFIG_FILE=examples/gateway-config.yaml docker-compose --profile validate up gal-validate

Environment Variables

  • PROVIDER: Gateway-Provider (envoy, kong, apisix, traefik)
  • CONFIG_FILE: Pfad zur Konfigurationsdatei
  • OUTPUT_DIR: Ausgabeverzeichnis für generierte Configs

Dokumentation

Testing & Development

Tests ausführen

# Alle Tests
pytest

# Mit Coverage
pytest --cov=gal --cov-report=term-missing

# Spezifische Test-Datei
pytest tests/test_providers.py -v

# Mit Logging
pytest -v --log-cli-level=DEBUG

Test-Suite

  • 101 Tests mit 89% Code Coverage
  • Unit Tests für alle Module
  • Provider-spezifische Tests
  • CLI Tests mit Click CliRunner
  • End-to-End Workflow Tests
  • Deployment Tests (mit Mocking)
  • Real-World Szenario Tests

Code Quality

# Formatting mit black
black .

# Import sorting mit isort
isort .

# Linting mit flake8
flake8 .

CI/CD

Das Projekt verwendet GitHub Actions für kontinuierliche Integration:

Workflows

  1. Tests (.github/workflows/test.yml)

    • Läuft auf Python 3.10, 3.11, 3.12
    • Automatische Tests bei jedem Push/PR
    • Code Quality Checks
    • Coverage Reporting
  2. Docker Build (.github/workflows/docker-build.yml)

    • Automatischer Build und Push zu ghcr.io
    • Multi-Platform Support (amd64, arm64)
    • Intelligentes Tagging (semver, branch, sha)
  3. Release (.github/workflows/release.yml)

    • Automatische Releases bei Git Tags
    • Changelog-Generierung
    • Package Building
    • GitHub Release Creation

Release erstellen

# Version Tag erstellen
git tag v1.0.1
git push origin v1.0.1

# GitHub Actions erstellt automatisch:
# - GitHub Release mit Changelog
# - Docker Images auf ghcr.io
# - Distribution Packages

Contributing

Beiträge sind willkommen! Bitte:

  1. Fork das Repository
  2. Erstelle einen Feature Branch (git checkout -b feature/amazing-feature)
  3. Committe deine Änderungen (git commit -m 'Add amazing feature')
  4. Pushe zum Branch (git push origin feature/amazing-feature)
  5. Öffne einen Pull Request

Richtlinien

  • Schreibe Tests für neue Features
  • Befolge den bestehenden Code-Stil
  • Aktualisiere die Dokumentation
  • Füge Eintrag im CHANGELOG.md hinzu

Lizenz

MIT - siehe LICENSE für Details.

Links

Autor

Dietmar Burkard - Gateway Abstraction Layer


⭐ Wenn dir dieses Projekt gefällt, gib ihm einen Stern auf GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gal_gateway-1.1.0.tar.gz (151.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gal_gateway-1.1.0-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

Details for the file gal_gateway-1.1.0.tar.gz.

File metadata

  • Download URL: gal_gateway-1.1.0.tar.gz
  • Upload date:
  • Size: 151.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for gal_gateway-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3b2a3bf36aaf64a554cc96fe04e975481169c03bc7e447a0974acb4d85be9264
MD5 768479f774e3a237471c523bade4c97a
BLAKE2b-256 eeef325666b319a1ffe33ab1de052d9e1fa9d607118287b102750da2745e0b56

See more details on using hashes here.

File details

Details for the file gal_gateway-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: gal_gateway-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for gal_gateway-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ddbd849b79010b124684a8937b0f3b5acc521ac93010f42d752c7b0b6cbb10ee
MD5 5f4e6927b1dc3db91fbe50a90fda9fdc
BLAKE2b-256 537e3f621646b34df4964e168aa1563a125596864284aa373e5e4916fe4cd934

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page