mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Fix environment variables who contains spaces in their value
If you have a `.env` file with some environment variables who contains spaces, like this: DB_INITIALIZE="cd /app && RAILS_ENV=production bin/setup" DB_MIGRATE="cd /app && RAILS_ENV=production bin/update"
This commit is contained in:
parent
79d3b5e775
commit
0828e59bc7
4
psu
4
psu
@ -393,7 +393,7 @@ deploy() {
|
|||||||
if [ -n "$ENVIRONMENT_VARIABLES_FILE" ]; then
|
if [ -n "$ENVIRONMENT_VARIABLES_FILE" ]; then
|
||||||
local new_stack_envvars
|
local new_stack_envvars
|
||||||
new_stack_envvars=$(env_file_to_json)
|
new_stack_envvars=$(env_file_to_json)
|
||||||
stack_envvars="$(echo -n "${new_stack_envvars}${stack_envvars}" | jq -sjc 'add | unique_by(.name)')"
|
stack_envvars="$(echo "${new_stack_envvars}${stack_envvars}" | jq -sjc 'add | unique_by(.name)')"
|
||||||
fi
|
fi
|
||||||
local data_prefix="{\"Id\":\"$stack_id\",\"StackFileContent\":\""
|
local data_prefix="{\"Id\":\"$stack_id\",\"StackFileContent\":\""
|
||||||
local data_suffix="\",\"Env\":"$stack_envvars",\"Prune\":$PORTAINER_PRUNE}"
|
local data_suffix="\",\"Env\":"$stack_envvars",\"Prune\":$PORTAINER_PRUNE}"
|
||||||
@ -470,7 +470,7 @@ undeploy() {
|
|||||||
# JSON string #
|
# JSON string #
|
||||||
###################################################
|
###################################################
|
||||||
env_file_to_json() {
|
env_file_to_json() {
|
||||||
echo "$(env -i $(cat $ENVIRONMENT_VARIABLES_FILE) jq -n 'env | to_entries | map({name: .key, value: .value})')"
|
echo "$(env -i sh -c "(unset \$(env | sed 's/=.*//'); set -a; . $ENVIRONMENT_VARIABLES_FILE; set +a; jq -njc 'env | to_entries | map({name: .key, value: .value})')")"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user