Skip to content

Commit

Permalink
Add eval to path so it supports env (#114)
Browse files Browse the repository at this point in the history
* Add eval to path so it supports env

* Fix shellcheck
  • Loading branch information
marboledacci authored Nov 8, 2024
1 parent d23e5e4 commit bd238b1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
6 changes: 4 additions & 2 deletions src/scripts/apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions src/scripts/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions src/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/scripts/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bd238b1

Please sign in to comment.