From a761184725bf27fe848261fb1a3c2f5676941a5a Mon Sep 17 00:00:00 2001 From: Juan Abia Date: Thu, 23 Feb 2023 10:56:00 +0100 Subject: [PATCH] Modify CIV options With the previous method of passing options, we encountered some problems when sending the options via an array. --- test/cases/aws.sh | 20 ++++++++++++++------ test/cases/azure.sh | 20 ++++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/test/cases/aws.sh b/test/cases/aws.sh index d2f2f0024..9e979efdf 100755 --- a/test/cases/aws.sh +++ b/test/cases/aws.sh @@ -199,14 +199,13 @@ greenprint "Pulling cloud-image-val container" if [[ "$CI_PROJECT_NAME" =~ "cloud-image-val" ]]; then # If running on CIV, get dev container TAG=${CI_COMMIT_REF_SLUG} - if [ -z "${CIV_OPTIONS:-}" ]; then - echo "ERROR: Please provide the variable CIV_OPTIONS" - exit 1 - fi else # If not, get prod container TAG="prod" - CIV_OPTIONS=( -r=/tmp/resource-file.json -d -o=/tmp/report.xml -m="not pub" ) + CIV_OPTION_R="-r=/tmp/resource-file.json" + CIV_OPTION_D="-d" + CIV_OPTION_O="-o=/tmp/report.xml" + CIV_OPTION_M="-m not pub" fi CONTAINER_CLOUD_IMAGE_VAL="quay.io/cloudexperience/cloud-image-val-test:$TAG" @@ -234,6 +233,8 @@ if [ "$ARCH" == "aarch64" ]; then sed -i s/t3.medium/a1.large/ "${TEMPDIR}/resource-file.json" fi +# The weird sintax with the CIV_OPTION variables is due to problems with bash quoting and +# having options with whitespaces in them. Please do not spend more hours trying to fix it sudo "${CONTAINER_RUNTIME}" run \ -a stdout -a stderr \ -e AWS_ACCESS_KEY_ID="${V2_AWS_ACCESS_KEY_ID}" \ @@ -241,7 +242,14 @@ sudo "${CONTAINER_RUNTIME}" run \ -e AWS_REGION="${AWS_REGION}" \ -v "${TEMPDIR}":/tmp:Z \ "${CONTAINER_CLOUD_IMAGE_VAL}" \ - python cloud-image-val.py "${CIV_OPTIONS[@]}" && RESULTS=1 || RESULTS=0 + python cloud-image-val.py \ + ${CIV_OPTION_R:+"$CIV_OPTION_R"} \ + ${CIV_OPTION_O:+"$CIV_OPTION_O"} \ + ${CIV_OPTION_T:+"$CIV_OPTION_T"} \ + ${CIV_OPTION_M:+"$CIV_OPTION_M"} \ + ${CIV_OPTION_D:+"$CIV_OPTION_D"} \ + ${CIV_OPTION_S:+"$CIV_OPTION_S"} \ + && RESULTS=1 || RESULTS=0 mv "${TEMPDIR}"/report.html "${ARTIFACTS}" diff --git a/test/cases/azure.sh b/test/cases/azure.sh index 779eb0ba3..969e476c6 100755 --- a/test/cases/azure.sh +++ b/test/cases/azure.sh @@ -199,14 +199,13 @@ greenprint "Pulling cloud-image-val container" if [[ "$CI_PROJECT_NAME" =~ "cloud-image-val" ]]; then # If running on CIV, get dev container TAG=${CI_COMMIT_REF_SLUG} - if [ -z "${CIV_OPTIONS:-}" ]; then - echo "ERROR: Please provide the variable CIV_OPTIONS" - exit 1 - fi else # If not, get prod container TAG="prod" - CIV_OPTIONS=( -r=/tmp/resource-file.json -d -o=/tmp/report.xml -m="not pub" ) + CIV_OPTION_R="-r=/tmp/resource-file.json" + CIV_OPTION_D="-d" + CIV_OPTION_O="-o=/tmp/report.xml" + CIV_OPTION_M="-m not pub" fi CONTAINER_CLOUD_IMAGE_VAL="quay.io/cloudexperience/cloud-image-val-test:$TAG" @@ -230,6 +229,8 @@ tee "${TEMPDIR}/resource-file.json" <