1
0
Fork 0

Refactor E2E tests and configuration format

- Replaced `easymapping` configuration with `containers` for better maintainability and clarity.
- Introduced `DockerComposeFixture` class in `utils.py` to manage Docker Compose lifecycle and smart build strategy.
- Enhanced YAML-to-environment variable conversion in `ContainerEnv` for dynamic configuration support.
- Updated HAProxy configurations and test fixtures to reflect the new format.
- Improved test coverage for YAML parsing, environment variable handling, and HAProxy config generation.
This commit is contained in:
Joao Gilberto Magalhaes 2026-02-13 11:44:26 -05:00
parent c125985150
commit 97845b8a52
22 changed files with 1042 additions and 442 deletions

View file

@ -74,15 +74,13 @@ spec:
```yaml
# /etc/haproxy/static/config.yaml
easymapping:
- host: example.com
port: 80
container: webapp:80
plugins:
- deny_pages
plugin_config:
containers:
"example.com:80":
ip: ["webapp:80"]
plugins: [deny_pages]
plugin:
deny_pages:
paths: /admin,/private,/debug
paths: [/admin, /private, /debug]
status_code: 403
```

View file

@ -228,13 +228,12 @@ spec:
```yaml
# /etc/haproxy/static/config.yaml
easymapping:
- host: api.example.com
port: 443
container: api-service:8080
plugins:
- jwt_validator
plugin_config:
containers:
"api.example.com:443":
ip: ["api-service:8080"]
ssl: true
plugins: [jwt_validator]
plugin:
jwt_validator:
algorithm: RS256
issuer: https://auth.example.com/

View file

@ -29,39 +29,43 @@ ssl_mode: default
logLevel:
haproxy: INFO
certbot: {
"email": "acme@example.org"
}
certbot:
email: "acme@example.org"
easymapping:
- port: 80
hosts:
host1.com.br:
containers:
- container:5000
certbot: true
redirect_ssl: true
host2.com.br:
containers:
- other:3000
redirect:
www.host1.com.br: http://host1.com.br
containers:
# HTTP with certbot + redirect to HTTPS
"host1.com.br:80":
ip: ["container:5000"]
certbot: true
redirect_ssl: true
- port: 443
hosts:
host1.com.br:
containers:
- container:80
redirect_ssl: false
ssl: true
# Additional HTTP host
"host2.com.br:80":
ip: ["other:3000"]
- port: 8080
hosts:
host3.com.br:
containers:
- domain:8181
# Redirect www → main domain
"www.host1.com.br:80":
ip: ["container:5000"]
redirect_ssl: true
# HTTPS version
"host1.com.br:443":
ip: ["container:80"]
ssl: true
# Different host on different port
"host3.com.br:8080":
ip: ["domain:8181"]
```
:::info New Configuration Format
The `containers` format simplifies static configuration:
- **Flatter structure**: `"hostname:port"` keys instead of nested `easymapping``ports``hosts`
- **Better readability**: Port and localport embedded in keys (`"host:port"` and `"container:localport"`)
- **Plugin support**: Global and per-host plugin configuration
- **Clearer mapping**: Format mirrors internal Docker label structure
:::
Then map this file to `/etc/haproxy/static/config.yml` in your EasyHAProxy container:
```bash title="Run EasyHAProxy with static configuration"
@ -109,19 +113,23 @@ certbot:
retry_count: 60 # If the certificate reaches the Rate Limit, try again after 'n' iterations.
}
easymapping:
- port: 80 # Listen port
containers:
# Format: "hostname:port"
"host1.com.br:80":
ip: ["container:5000"] # Endpoints (ip, dns, container, etc) with format "address:localport"
certbot: true # Optional. Request a certbot certificate. Requires certbot.email set.
redirect_ssl: true # Optional. Redirect HTTP to HTTPS for this host.
mode: http # Optional. Default `http`. Can be http or tcp
hosts:
host1.com.br: # Hostname
containers:
- container:5000 # Endpoints of the hostname above (ip, dns, container, etc)
certbot: true # Optional. it will request a certbot certificate. Needs certbot.email set.
redirect_ssl: true # Optional. It will redirect this site to it SSL.
ssl: true # Optional. Inform this port will listen to SSL, instead of HTTP
clone_to_ssl: true # Optional. Default False. You clone these hosts to its equivalent SSL.
redirect:
www.host1.com.br: http://host1.com.br
# HTTPS version (SSL)
"host1.com.br:443":
ip: ["container:80"]
ssl: true # Enable SSL for this port
# Redirect www → main domain (using redirect_ssl with backend)
"www.host1.com.br:80":
ip: ["container:5000"]
redirect_ssl: true
```
:::note SSL Certificates in Static Mode