diff --git a/.catalog-onboard-pipeline.yaml b/.catalog-onboard-pipeline.yaml index fbcfc416..f7d8e1ee 100644 --- a/.catalog-onboard-pipeline.yaml +++ b/.catalog-onboard-pipeline.yaml @@ -9,6 +9,8 @@ offerings: - name: fully-configurable mark_ready: true install_type: fullstack + pre_validation: "tests/scripts/pre-validation-deploy-cloud-logs.sh" + post_validation: "tests/scripts/post-validation-destroy-cloud-logs.sh" scc: instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37 region: us-south diff --git a/tests/scripts/post-validation-destroy-cloud-logs.sh b/tests/scripts/post-validation-destroy-cloud-logs.sh new file mode 100755 index 00000000..4c3eb17a --- /dev/null +++ b/tests/scripts/post-validation-destroy-cloud-logs.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +############################################################################################################# +# This script is used by the catalog pipeline to destroy the COS instance and VPC, which were provisioned # +# as prerequisites for the fully configurable OCP VPC cluster that is published to the catalog. # +############################################################################################################# + +set -e + +TERRAFORM_SOURCE_DIR="tests/resources" +TF_VARS_FILE="terraform.tfvars" + +( + cd "${TERRAFORM_SOURCE_DIR}" + echo "Destroying pre-requisite Cloud Logs instance..." + terraform destroy -input=false -auto-approve -var-file="${TF_VARS_FILE}" || exit 1 + rm "${TF_VARS_FILE}" || exit 1 + + echo "Post-validation completed successfully." +) diff --git a/tests/scripts/pre-validation-deploy-cloud-logs.sh b/tests/scripts/pre-validation-deploy-cloud-logs.sh new file mode 100755 index 00000000..06d0dc8b --- /dev/null +++ b/tests/scripts/pre-validation-deploy-cloud-logs.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +############################################################################################################ +## This script is used by the catalog pipeline to deploy the Cloud Logs instance +## which are the prerequisites for the fully-configurable AT Event Routing DA. +############################################################################################################ + +set -e + +DA_DIR="solutions/fully-configurable" +TERRAFORM_SOURCE_DIR="tests/resources" +JSON_FILE="${DA_DIR}/catalogValidationValues.json" +TF_VARS_FILE="terraform.tfvars" + +( + cwd=$(pwd) + cd ${TERRAFORM_SOURCE_DIR} + echo "Provisioning pre-requisite Cloud Logs instance .." + terraform init || exit 1 + + # $VALIDATION_APIKEY is available in the catalog runtime + { + echo "ibmcloud_api_key=\"${VALIDATION_APIKEY}\"" + echo "prefix=\"at-$(openssl rand -hex 2)\"" + } >> ${TF_VARS_FILE} + terraform apply -input=false -auto-approve -var-file=${TF_VARS_FILE} || exit 1 + + existing_cloud_logs_instance_crn="existing_cloud_logs_instance_crn" + existing_cloud_logs_instance_value=$(terraform output -state=terraform.tfstate -raw icl_crn) + + echo "Appending '${existing_cloud_logs_instance_crn}' input variable values to ${JSON_FILE}.." + + cd "${cwd}" + jq -r --arg existing_cloud_logs_instance_crn "${existing_cloud_logs_instance_crn}" \ + --arg existing_cloud_logs_instance_value "${existing_cloud_logs_instance_value}" \ + '. + {($existing_cloud_logs_instance_crn): $existing_cloud_logs_instance_value}' "${JSON_FILE}" > tmpfile && mv tmpfile "${JSON_FILE}" || exit 1 + + echo "Pre-validation completed successfully." +)