Skip to content

Commit daec682

Browse files
authored
fix: Improve README and drop quotes from hook env vars (#651)
1 parent 1bdc82b commit daec682

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,18 @@ If for config above set up `export CONFIG_NAME=.tflint; export CONFIG_EXT=hcl` b
322322

323323
You can specify environment variables that will be passed to the hook at runtime.
324324

325+
> [!IMPORTANT]
326+
> Variable values are exported _verbatim_:
327+
> - No interpolation or expansion are applied
328+
> - The enclosing double quotes are removed if they are provided
329+
325330
Config example:
326331

327332
```yaml
328333
- id: terraform_validate
329334
args:
330335
- --env-vars=AWS_DEFAULT_REGION="us-west-2"
331-
- --env-vars=AWS_ACCESS_KEY_ID="anaccesskey"
332-
- --env-vars=AWS_SECRET_ACCESS_KEY="asecretkey"
336+
- --env-vars=AWS_PROFILE="my-aws-cli-profile"
333337
```
334338

335339
### All hooks: Disable color output

hooks/_common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ function common::export_provided_env_vars {
527527
for var in "${env_vars[@]}"; do
528528
var_name="${var%%=*}"
529529
var_value="${var#*=}"
530+
# Drop enclosing double quotes
531+
if [[ $var_value =~ ^\" && $var_value =~ \"$ ]]; then
532+
var_value="${var_value#\"}"
533+
var_value="${var_value%\"}"
534+
fi
530535
# shellcheck disable=SC2086
531536
export $var_name="$var_value"
532537
done

0 commit comments

Comments
 (0)