|
51 | 51 | type: filesystem |
52 | 52 | path: /var/lib/mantle/artifacts |
53 | 53 | retention: "24h" |
| 54 | + |
| 55 | +env: |
| 56 | + APP_NAME: "my-app" |
| 57 | + API_BASE_URL: "https://api.example.com" |
54 | 58 | ``` |
55 | 59 |
|
56 | 60 | ### All Config File Fields |
|
80 | 84 | | `tmp.prefix` | string | -- | S3 key prefix for artifact storage. Optional. | |
81 | 85 | | `tmp.path` | string | -- | Local directory path. Required when `tmp.type` is `filesystem`. | |
82 | 86 | | `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). | |
83 | 88 |
|
84 | 89 | ### Config File Discovery |
85 | 90 |
|
86 | 91 | 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`. |
87 | 92 |
|
88 | 93 | 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. |
89 | 94 |
|
| 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 | + |
90 | 154 | ## Environment Variables |
91 | 155 |
|
92 | 156 | All environment variables use the `MANTLE_` prefix with underscores replacing dots and hyphens. |
|
0 commit comments