sqitchers / docker-sqitch

Docker Image packaging for Sqitch
MIT License
35 stars 39 forks source link

sqitch script not setting environment variables. #35

Closed venkatra closed 3 years ago

venkatra commented 3 years ago

Currently in the script : docker-sqitch.sh ; You are iterating the various engine specific environment variables and passing to the docker.

bash do if [ -n "${!var}" ]; then passopt+=(-e $var) fi done However when the script runs, in my case i was using Snowflake, it does not set the actual value. This is the debug output:

`

Notice that the value for -e SNOWSQL_ACCOUNT -e SNOWSQL_USER etc.. are not set.

I made some update in the script as below

bash do if [ -n "${!var}" ]; then var_val=printf '%s\n' "${!var}" passopt+=(-e "$var=${var_val}") fi done

Notice var_val=printf '%s\n' "${!var}";passopt+=(-e "$var=${var_val}") fixed the issue. Now the same script pass the env to the docker:

`bash

Hope this can be adderesed in future release

theory commented 3 years ago

Notice that the value for -e SNOWSQL_ACCOUNT -e SNOWSQL_USER etc.. are not set.

Yeah, it doesn't have to. The docker run --env docs say:

You can also use variables that you’ve exported to your local environment:

export VAR1=value1
export VAR2=value2

$ docker run --env VAR1 --env VAR2 ubuntu env | grep VAR
VAR1=value1
VAR2=value2

So it's not necessary to copy the values.