From e62f1280e8d271132e5157303b6223c559a67508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= Date: Tue, 7 May 2024 16:22:14 +0200 Subject: [PATCH] fix shell check issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weiße --- .../e2e_cleanup_timeframe/e2e-cleanup.sh | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh b/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh index 4c7672018..a88e714c5 100755 --- a/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh +++ b/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh @@ -3,7 +3,7 @@ # get_e2e_test_ids_on_date gets all workflow IDs of workflows that contain "e2e" on a specific date. function get_e2e_test_ids_on_date { ids="$(gh run list --created "$1" --status failure --json createdAt,workflowName,databaseId --jq '.[] | select(.workflowName | contains("e2e") and (contains("MiniConstellation") | not)) | .databaseId' -L1000 -R edgelesssys/constellation || exit 1)" - echo "$ids" + echo "${ids}" } # download_tfstate_artifact downloads all artifacts matching the pattern terraform-state-* from a given workflow ID. @@ -13,7 +13,7 @@ function download_tfstate_artifact { # delete_resources runs terraform destroy on the constellation-terraform subfolder of a given folder. function delete_resources { - if [ -d "$1/constellation-terraform" ]; then + if [[ -d "$1/constellation-terraform" ]]; then cd "$1/constellation-terraform" || exit 1 terraform init > /dev/null || exit 1 # first, install plugins terraform destroy -auto-approve || exit 1 @@ -23,7 +23,7 @@ function delete_resources { # delete_iam_config runs terraform destroy on the constellation-iam-terraform subfolder of a given folder. function delete_iam_config { - if [ -d "$1/constellation-iam-terraform" ]; then + if [[ -d "$1/constellation-iam-terraform" ]]; then cd "$1/constellation-iam-terraform" || exit 1 terraform init > /dev/null || exit 1 # first, install plugins terraform destroy -auto-approve || exit 1 @@ -32,12 +32,12 @@ function delete_iam_config { } # check if the password for artifact decryption was given -if [[ -z $ENCRYPTION_SECRET ]]; then +if [[ -z ${ENCRYPTION_SECRET} ]]; then echo "ENCRYPTION_SECRET is not set. Please set an environment variable with that secret." exit 1 fi -artifact_pwd=$ENCRYPTION_SECRET +artifact_pwd=${ENCRYPTION_SECRET} shopt -s nullglob @@ -46,9 +46,9 @@ end_date=$(date --date "-7 day" "+%Y-%m-%d") dates_to_clean=() # get all dates of the last week -while [[ $end_date != "$start_date" ]]; do - dates_to_clean+=("$end_date") - end_date=$(date --date "$end_date +1 day" "+%Y-%m-%d") +while [[ ${end_date} != "${start_date}" ]]; do + dates_to_clean+=("${end_date}") + end_date=$(date --date "${end_date} +1 day" "+%Y-%m-%d") done echo "[*] retrieving run IDs for cleanup" @@ -65,33 +65,33 @@ mapfile -td " " database_ids < <(echo "${database_ids[@]}") echo "[*] downloading terraform state artifacts" for id in "${database_ids[@]}"; do - if [[ $id == *[^[:space:]]* ]]; then - echo " downloading from workflow $id" - download_tfstate_artifact "$id" + if [[ ${id} == *[^[:space:]]* ]]; then + echo " downloading from workflow ${id}" + download_tfstate_artifact "${id}" fi done echo "[*] extracting artifacts" for directory in ./terraform-state-*; do - echo " extracting $directory" + echo " extracting ${directory}" # extract and decrypt the artifact 7zz x -t7z -p"${artifact_pwd}" -o"${directory}" "${directory}/archive.7z" > /dev/null || exit 1 done # create terraform caching directory -mkdir "$HOME/tf_plugin_cache" -export TF_PLUGIN_CACHE_DIR="$HOME/tf_plugin_cache" -echo "[*] created terraform cache directory $TF_PLUGIN_CACHE_DIR" +mkdir "${HOME}/tf_plugin_cache" +export TF_PLUGIN_CACHE_DIR="${HOME}/tf_plugin_cache" +echo "[*] created terraform cache directory ${TF_PLUGIN_CACHE_DIR}" echo "[*] deleting resources" for directory in ./terraform-state-*; do - echo " deleting resources in $directory" - delete_resources "$directory" - echo " deleting IAM configuration in $directory" - delete_iam_config "$directory" - echo " deleting directory $directory" - rm -rf "$directory" + echo " deleting resources in ${directory}" + delete_resources "${directory}" + echo " deleting IAM configuration in ${directory}" + delete_iam_config "${directory}" + echo " deleting directory ${directory}" + rm -rf "${directory}" done exit 0