-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev_container.sh
executable file
·32 lines (26 loc) · 1.39 KB
/
dev_container.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
get_host_architecture_for_debian_packages() {
if [[ $(uname -m) == 'arm64' ]]; then
echo arm64
else
echo amd64
fi
}
initialize() {
# Write .arch
get_host_architecture_for_debian_packages > .devcontainer/.arch
}
post_attach() {
# Used to apply secrets from the VS Code Remote Container to the SQLTool
# extension settings. Unfortunately, the SQLTools extension does not support
# reading using VS Code environment variables. See here for more details:
# https://github.com/mtxr/vscode-sqltools/issues/452
CONTAINER_SETTINGS_PATH=/root/.vscode-server/data/Machine/settings.json
TEMP=$CONTAINER_SETTINGS_PATH.temp
jq --arg var "$SNOWFLAKE_ACCOUNT" '."sqltools.connections"[0].server = $var' $CONTAINER_SETTINGS_PATH > $TEMP && mv $TEMP $CONTAINER_SETTINGS_PATH
jq --arg var "$SNOWFLAKE_USER" '."sqltools.connections"[0].database = $var' $CONTAINER_SETTINGS_PATH > $TEMP && mv $TEMP $CONTAINER_SETTINGS_PATH
jq --arg var "$SNOWFLAKE_DATABASE" '."sqltools.connections"[0].username = $var' $CONTAINER_SETTINGS_PATH > $TEMP && mv $TEMP $CONTAINER_SETTINGS_PATH
jq --arg var "$SNOWFLAKE_PASSWORD" '."sqltools.connections"[0].password = $var' $CONTAINER_SETTINGS_PATH > $TEMP && mv $TEMP $CONTAINER_SETTINGS_PATH
jq --arg var "$SNOWFLAKE_WAREHOUSE" '."sqltools.connections"[0].password = $var' $CONTAINER_SETTINGS_PATH > $TEMP && mv $TEMP $CONTAINER_SETTINGS_PATH
}
"$@"