Skip to content

Commit abc98de

Browse files
michaelmcneesclaude
andcommitted
docs: document env: config section for workflow variables (#74)
Add Workflow Expression Variables section to configuration docs covering the env: YAML syntax, CEL expression usage, and MANTLE_ENV_* override precedence with info logging on conflicts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4663b86 commit abc98de

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

packages/site/src/content/docs/configuration.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ tmp:
5151
type: filesystem
5252
path: /var/lib/mantle/artifacts
5353
retention: "24h"
54+
55+
env:
56+
APP_NAME: "my-app"
57+
API_BASE_URL: "https://api.example.com"
5458
```
5559
5660
### All Config File Fields
@@ -80,13 +84,73 @@ tmp:
8084
| `tmp.prefix` | string | -- | S3 key prefix for artifact storage. Optional. |
8185
| `tmp.path` | string | -- | Local directory path. Required when `tmp.type` is `filesystem`. |
8286
| `tmp.retention` | duration | -- | How long to keep artifacts after workflow completion. Uses Go duration format (e.g., `24h`). Empty means no auto-cleanup. |
87+
| `env.*` | map[string]string | -- | Key-value pairs available to CEL workflow expressions via `env.<KEY>`. See [Workflow Expression Variables](#workflow-expression-variables). |
8388

8489
### Config File Discovery
8590

8691
When you do not pass `--config`, Mantle searches for `mantle.yaml` in the current directory. If no config file is found, Mantle silently falls back to defaults. This is intentional -- most commands work fine with defaults when you use the provided `docker-compose.yml`.
8792

8893
When you pass `--config path/to/config.yaml` explicitly, Mantle requires that file to exist and be valid YAML. A missing or unparseable explicit config file is a hard error.
8994

95+
## Workflow Expression Variables
96+
97+
The `env:` section in `mantle.yaml` defines key-value pairs that are available to CEL expressions in workflows via the `env` namespace. This is useful for environment-specific configuration that workflows need at runtime (API base URLs, feature flags, region names, etc.) without hardcoding values in workflow definitions.
98+
99+
### Syntax
100+
101+
```yaml
102+
# mantle.yaml
103+
env:
104+
APP_NAME: "my-app"
105+
API_BASE_URL: "https://api.example.com"
106+
REGION: "us-east-1"
107+
DEBUG: "true"
108+
```
109+
110+
### Usage in Workflows
111+
112+
Values defined in the `env:` section are accessible in any CEL expression via `env.<KEY>`:
113+
114+
```yaml
115+
# workflow.yaml
116+
name: deploy
117+
steps:
118+
- name: notify
119+
connector: http/request
120+
params:
121+
url: "{{ env.API_BASE_URL }}/deployments"
122+
body: '{"app": "{{ env.APP_NAME }}", "region": "{{ env.REGION }}"}'
123+
```
124+
125+
### Precedence
126+
127+
The `env:` config values merge with `MANTLE_ENV_*` OS environment variables. When the same key exists in both sources, the OS environment variable wins:
128+
129+
1. **`MANTLE_ENV_*` environment variables** (highest priority) -- stripped of the `MANTLE_ENV_` prefix
130+
2. **`env:` section in `mantle.yaml`** (lower priority)
131+
132+
When an override occurs, Mantle logs an info message:
133+
134+
```
135+
INFO env variable overrides config key=MANTLE_ENV_REGION config_key=env.REGION
136+
```
137+
138+
This allows operators to override config-file defaults without editing YAML, which is useful in CI pipelines and container deployments.
139+
140+
**Example override:**
141+
142+
```yaml
143+
# mantle.yaml
144+
env:
145+
REGION: "us-east-1"
146+
```
147+
148+
```bash
149+
# Override REGION for this deployment
150+
export MANTLE_ENV_REGION="eu-west-1"
151+
mantle run deploy # env.REGION evaluates to "eu-west-1"
152+
```
153+
90154
## Environment Variables
91155

92156
All environment variables use the `MANTLE_` prefix with underscores replacing dots and hyphens.

0 commit comments

Comments
 (0)