From 16e173d05ec14ddf68db3e4c03661e02aa2f0e59 Mon Sep 17 00:00:00 2001 From: Jason Jones Date: Thu, 10 Apr 2025 15:52:21 -0400 Subject: [PATCH 1/3] update: support env replacement in hop proxy --- bin/_helpers | 4 ++++ bin/proxy | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/bin/_helpers b/bin/_helpers index 33caa48..727e5b4 100644 --- a/bin/_helpers +++ b/bin/_helpers @@ -94,6 +94,10 @@ function output_info { output_tagged_string "$BG_B" "INFO" "$1" } +function output_warning { + output_tagged_string "$BG_Y" "INFO" "$1" +} + export BG_R export BG_G export BG_Y diff --git a/bin/proxy b/bin/proxy index f1015ba..64cf346 100755 --- a/bin/proxy +++ b/bin/proxy @@ -1,5 +1,15 @@ #!/usr/bin/env bash +# Enable auto-export +set -a + +if [ -f ".env" ]; then + source ".env" +fi + +# Disable auto-export +set +a + HOP_PATH=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) TOOLKIT_PATH=$(dirname "$HOP_PATH") @@ -147,6 +157,16 @@ function pick_one_virtual_host_from_file() { HOST_STRING=$(sed -nr 's/.*VIRTUAL_HOST=(.*)/\1/p' "$FILE") + # Trim double quotes from HOST_STRING + HOST_STRING=$(echo "$HOST_STRING" | tr -d '"') + + # Pipe HOST_STRING through envsubst if available + if command -v envsubst &> /dev/null; then + HOST_STRING=$(echo "$HOST_STRING" | envsubst) + else + >&2 output_warning "envsubst not found. Skipping environment variable substitution." + fi + IFS="," read -ra HOSTS <<< "$HOST_STRING" for HOST_ENTRY in "${HOSTS[@]}"; do From 2382c09641abf8569b36c95a83b280ba370a547b Mon Sep 17 00:00:00 2001 From: Jason Jones Date: Thu, 10 Apr 2025 16:01:44 -0400 Subject: [PATCH 2/3] update: label warning output properly --- bin/_helpers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/_helpers b/bin/_helpers index 727e5b4..e0bd47b 100644 --- a/bin/_helpers +++ b/bin/_helpers @@ -95,7 +95,7 @@ function output_info { } function output_warning { - output_tagged_string "$BG_Y" "INFO" "$1" + output_tagged_string "$BG_Y" "WARNING" "$1" } export BG_R From a2257ded9fe3b258ba090fe42144ca7f76aac425 Mon Sep 17 00:00:00 2001 From: Jason Jones Date: Thu, 10 Apr 2025 16:05:10 -0400 Subject: [PATCH 3/3] style: fix lint issue --- bin/proxy | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/proxy b/bin/proxy index 64cf346..98ea3b3 100755 --- a/bin/proxy +++ b/bin/proxy @@ -4,6 +4,7 @@ set -a if [ -f ".env" ]; then + # shellcheck source=/dev/null source ".env" fi