From bd238b1bd9dfd89a092afc27d38d46833d91e173 Mon Sep 17 00:00:00 2001 From: marboledacci Date: Fri, 8 Nov 2024 09:40:41 -0500 Subject: [PATCH] Add eval to path so it supports env (#114) * Add eval to path so it supports env * Fix shellcheck --- src/scripts/apply.sh | 6 ++++-- src/scripts/destroy.sh | 7 ++++--- src/scripts/init.sh | 9 ++++++--- src/scripts/plan.sh | 7 +++++-- src/scripts/validate.sh | 9 ++++++--- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/scripts/apply.sh b/src/scripts/apply.sh index 0f60f4c..cc2d8d0 100644 --- a/src/scripts/apply.sh +++ b/src/scripts/apply.sh @@ -9,8 +9,10 @@ if [[ -n "${TF_PARAM_CLI_CONFIG_FILE}" ]]; then fi fi # 'path' is a required parameter, save it as module_path -readonly module_path="${TF_PARAM_PATH}" -export path=$module_path +module_path="$(eval echo "$TF_PARAM_PATH")" +readonly module_path +path=$module_path +export path if [[ ! -d "$module_path" ]]; then echo "Path does not exist: $module_path" diff --git a/src/scripts/destroy.sh b/src/scripts/destroy.sh index b0ac96e..10187b3 100644 --- a/src/scripts/destroy.sh +++ b/src/scripts/destroy.sh @@ -10,9 +10,10 @@ if [[ -n "${TF_PARAM_CLI_CONFIG_FILE}" ]]; then fi # 'path' is a required parameter, save it as module_path -readonly module_path="${TF_PARAM_PATH}" - -export path=$module_path +module_path="$(eval echo "$TF_PARAM_PATH")" +readonly module_path +path=$module_path +export path if [[ ! -d "$module_path" ]]; then echo "Path does not exist: $module_path" diff --git a/src/scripts/init.sh b/src/scripts/init.sh index 93fbce6..d94e207 100644 --- a/src/scripts/init.sh +++ b/src/scripts/init.sh @@ -9,15 +9,18 @@ if [[ -n "${TF_PARAM_CLI_CONFIG_FILE}" ]]; then fi fi # 'path' is a required parameter, save it as module_path -readonly module_path="${TF_PARAM_PATH}" -export path=$module_path +module_path="$(eval echo "$TF_PARAM_PATH")" +readonly module_path +path=$module_path +export path -export backend="${TF_PARAM_BACKEND}" if [[ ! -d "$module_path" ]]; then echo "Path does not exist: $module_path" exit 1 fi +backend="${TF_PARAM_BACKEND}" +export backend # Initialize terraform if [[ -n "${TF_PARAM_BACKEND_CONFIG_FILE}" ]]; then diff --git a/src/scripts/plan.sh b/src/scripts/plan.sh index 529257b..737b291 100644 --- a/src/scripts/plan.sh +++ b/src/scripts/plan.sh @@ -9,8 +9,11 @@ if [[ -n "${TF_PARAM_CLI_CONFIG_FILE}" ]]; then fi fi # 'path' is a required parameter, save it as module_path -readonly module_path="${TF_PARAM_PATH}" -export path=$module_path + +module_path="$(eval echo "$TF_PARAM_PATH")" +readonly module_path +path=$module_path +export path if [[ ! -d "$module_path" ]]; then echo "Path does not exist: $module_path" exit 1 diff --git a/src/scripts/validate.sh b/src/scripts/validate.sh index 0c50d47..932d0c9 100644 --- a/src/scripts/validate.sh +++ b/src/scripts/validate.sh @@ -8,9 +8,12 @@ if [[ -n "${TF_PARAM_CLI_CONFIG_FILE}" ]]; then exit 1 fi fi -export path=$TF_PARAM_PATH -if [[ ! -d "$TF_PARAM_PATH" ]]; then - echo "Path does not exist: $TF_PARAM_PATH" +module_path="$(eval echo "$TF_PARAM_PATH")" +readonly module_path +path=$module_path +export path +if [[ ! -d "$module_path" ]]; then + echo "Path does not exist: $module_path" exit 1 fi