@@ -14,7 +14,7 @@ export TF_CLI_ARGS_plan="${TF_CLI_ARGS_plan} -lock-timeout=5m"
1414export TF_CLI_ARGS_apply=" ${TF_CLI_ARGS_apply} -lock-timeout=5m"
1515
1616if [ -n " ${DESTROY-} " ]; then
17- export TF_CLI_ARGS_plan=" ${TF_CLI_ARGS_plan} -destroy"
17+ export TF_CLI_ARGS_plan=" ${TF_CLI_ARGS_plan} -destroy"
1818fi
1919
2020function check_workspace() {
@@ -58,6 +58,7 @@ function terraform_init() {
5858 terraform init
5959 if [ -n " ${WORKSPACE-} " ]; then
6060 set_workspace " ${WORKSPACE} "
61+ check_workspace " ${WORKSPACE} "
6162 fi
6263
6364 popd || return " ${ERROR_CHANGE_DIR} "
@@ -78,6 +79,7 @@ function terraform_plan() {
7879
7980 # check if we should be in a workspace, and bail otherwise
8081 if [ -n " ${WORKSPACE-} " ]; then
82+ set_workspace " ${WORKSPACE} "
8183 check_workspace " ${WORKSPACE} "
8284 fi
8385
@@ -104,18 +106,14 @@ function terraform_apply() {
104106
105107 pushd " ${target_dir} " || return " ${ERROR_CHANGE_DIR} "
106108
107- # check if we should be in a workspace, and bail otherwise
108- if [ -n " ${WORKSPACE-} " ]; then
109- check_workspace " ${WORKSPACE} "
110- fi
111-
112109 if [ -z " ${plan_location-} " ]; then
113110 log_error " Must provide PLAN_LOCATION for apply"
114111 return " ${ERROR_NO_PLAN} "
115112 fi
116113
117114 # check if we should be in a workspace, and bail otherwise
118115 if [ -n " ${WORKSPACE-} " ]; then
116+ set_workspace " ${WORKSPACE} "
119117 check_workspace " ${WORKSPACE} "
120118 fi
121119
0 commit comments