Skip to content

Commit 16e173d

Browse files
committed
update: support env replacement in hop proxy
1 parent 872ce00 commit 16e173d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

bin/_helpers

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ function output_info {
9494
output_tagged_string "$BG_B" "INFO" "$1"
9595
}
9696

97+
function output_warning {
98+
output_tagged_string "$BG_Y" "INFO" "$1"
99+
}
100+
97101
export BG_R
98102
export BG_G
99103
export BG_Y

bin/proxy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/usr/bin/env bash
22

3+
# Enable auto-export
4+
set -a
5+
6+
if [ -f ".env" ]; then
7+
source ".env"
8+
fi
9+
10+
# Disable auto-export
11+
set +a
12+
313
HOP_PATH=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
414
TOOLKIT_PATH=$(dirname "$HOP_PATH")
515

@@ -147,6 +157,16 @@ function pick_one_virtual_host_from_file() {
147157

148158
HOST_STRING=$(sed -nr 's/.*VIRTUAL_HOST=(.*)/\1/p' "$FILE")
149159

160+
# Trim double quotes from HOST_STRING
161+
HOST_STRING=$(echo "$HOST_STRING" | tr -d '"')
162+
163+
# Pipe HOST_STRING through envsubst if available
164+
if command -v envsubst &> /dev/null; then
165+
HOST_STRING=$(echo "$HOST_STRING" | envsubst)
166+
else
167+
>&2 output_warning "envsubst not found. Skipping environment variable substitution."
168+
fi
169+
150170
IFS="," read -ra HOSTS <<< "$HOST_STRING"
151171

152172
for HOST_ENTRY in "${HOSTS[@]}"; do

0 commit comments

Comments
 (0)