From d678f696ca8b9752dd7fc309076ee95ba01fb987 Mon Sep 17 00:00:00 2001 From: Isa Aguilar Date: Thu, 5 Oct 2023 08:50:30 -0400 Subject: [PATCH] shfmt -i 4 --- pkg/controllers/scripts/setup.sh | 55 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/pkg/controllers/scripts/setup.sh b/pkg/controllers/scripts/setup.sh index 68fd52e..c531039 100644 --- a/pkg/controllers/scripts/setup.sh +++ b/pkg/controllers/scripts/setup.sh @@ -44,33 +44,32 @@ if [[ ! -s "$TFO_MAIN_MODULE_ADDONS/inline-module.tf" ]]; then if [[ "$key" != *".tf" ]] || [[ "$key" != *".json" ]]; then suffix=".tf" # select tf as default fi - jq -r --arg key "$key" '.data[$key]' <<< $configmap_json > "${TFO_MAIN_MODULE}/${key}${suffix}" + jq -r --arg key "$key" '.data[$key]' <<<$configmap_json >"${TFO_MAIN_MODULE}/${key}${suffix}" else - for key in $(jq -r '.data | keys[]' <<< $configmap_json); do + for key in $(jq -r '.data | keys[]' <<<$configmap_json); do # No assumptions about the file types are made here. The user # should create keys that are properly suffixed for terraform. - jq -r --arg key "$key" '.data[$key]' <<< $configmap_json > "${TFO_MAIN_MODULE}/${key}" + jq -r --arg key "$key" '.data[$key]' <<<$configmap_json >"${TFO_MAIN_MODULE}/${key}" done fi # Check if this is a source directory instead of a git repo elif [[ "$TFO_MAIN_MODULE_REPO" == file://* ]]; then - local_module_path="${TFO_MAIN_MODULE_REPO#"file://"}" - if [[ -d "$local_module_path" ]]; then - cp -r "$local_module_path" "$TFO_MAIN_MODULE" - else - echo "terraform module file source: $local_module_path, does not exist" - exit 1 - fi + local_module_path="${TFO_MAIN_MODULE_REPO#"file://"}" + if [[ -d "$local_module_path" ]]; then + cp -r "$local_module_path" "$TFO_MAIN_MODULE" + else + echo "terraform module file source: $local_module_path, does not exist" + exit 1 + fi else # The terraform module is a repo that must be downloaded - MAIN_MODULE_TMP=`mktemp -d` - cd "$MAIN_MODULE_TMP" - git clone "$TFO_MAIN_MODULE_REPO" 2>&1 | tee .out + cd $(mktemp -d) + git clone "$TFO_MAIN_MODULE_REPO" 2>&1 | tee .out exit_code=${PIPESTATUS[0]} if [ $exit_code -ne 0 ]; then - exit $exit_code; + exit $exit_code fi - reponame=$(sed -n "s/.*'\([^']*\)'.*/\1/p" .out) + reponame=$(sed -n "s/.*'\([^']*\)'.*/\1/p" .out) cd "$reponame" git checkout "$TFO_MAIN_MODULE_REPO_REF" cp -r "$TFO_MAIN_MODULE_REPO_SUBDIR" "$TFO_MAIN_MODULE" @@ -91,24 +90,24 @@ if stat backend_override.tf >/dev/null 2>/dev/null; then else echo "Loading hashicorp backend" set -x - envsubst < /backend.tf > "$TFO_ROOT_PATH/backend_override.tf" + envsubst "$TFO_ROOT_PATH/backend_override.tf" mv "$TFO_ROOT_PATH/backend_override.tf" . fi function join_by { - local d="$1" f=${2:-$( $DATA + jq --argjson i $i '.[$i]' $FILE >$DATA fetchtype=$(jq -r '.detect' $DATA) repo=$(jq -r '.repo' $DATA) files=$(jq -r '.files[]' $DATA | join_by " ") path=$(jq -r '.path' $DATA) tfvar=$(jq -r '.useAsVar' $DATA) branch=$(jq -r '.hash' $DATA) - if [[ "$fetchtype" == "git" ]];then + if [[ "$fetchtype" == "git" ]]; then fetch_git "$repo" "$path" "$files" "$tfvar" "$branch" fi done