Skip to content

Commit d6e8f3e

Browse files
authored
fix: add pre-post validation script for catalog onboarding (#77)
1 parent d0c093c commit d6e8f3e

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

.catalog-onboard-pipeline.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ offerings:
99
- name: fully-configurable
1010
mark_ready: true
1111
install_type: fullstack
12+
pre_validation: "tests/scripts/pre-validation-deploy-cloud-logs.sh"
13+
post_validation: "tests/scripts/post-validation-destroy-cloud-logs.sh"
1214
scc:
1315
instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37
1416
region: us-south
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
#############################################################################################################
4+
# This script is used by the catalog pipeline to destroy the COS instance and VPC, which were provisioned #
5+
# as prerequisites for the fully configurable OCP VPC cluster that is published to the catalog. #
6+
#############################################################################################################
7+
8+
set -e
9+
10+
TERRAFORM_SOURCE_DIR="tests/resources"
11+
TF_VARS_FILE="terraform.tfvars"
12+
13+
(
14+
cd "${TERRAFORM_SOURCE_DIR}"
15+
echo "Destroying pre-requisite Cloud Logs instance..."
16+
terraform destroy -input=false -auto-approve -var-file="${TF_VARS_FILE}" || exit 1
17+
rm "${TF_VARS_FILE}" || exit 1
18+
19+
echo "Post-validation completed successfully."
20+
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
############################################################################################################
4+
## This script is used by the catalog pipeline to deploy the Cloud Logs instance
5+
## which are the prerequisites for the fully-configurable AT Event Routing DA.
6+
############################################################################################################
7+
8+
set -e
9+
10+
DA_DIR="solutions/fully-configurable"
11+
TERRAFORM_SOURCE_DIR="tests/resources"
12+
JSON_FILE="${DA_DIR}/catalogValidationValues.json"
13+
TF_VARS_FILE="terraform.tfvars"
14+
15+
(
16+
cwd=$(pwd)
17+
cd ${TERRAFORM_SOURCE_DIR}
18+
echo "Provisioning pre-requisite Cloud Logs instance .."
19+
terraform init || exit 1
20+
21+
# $VALIDATION_APIKEY is available in the catalog runtime
22+
{
23+
echo "ibmcloud_api_key=\"${VALIDATION_APIKEY}\""
24+
echo "prefix=\"at-$(openssl rand -hex 2)\""
25+
} >> ${TF_VARS_FILE}
26+
terraform apply -input=false -auto-approve -var-file=${TF_VARS_FILE} || exit 1
27+
28+
existing_cloud_logs_instance_crn="existing_cloud_logs_instance_crn"
29+
existing_cloud_logs_instance_value=$(terraform output -state=terraform.tfstate -raw icl_crn)
30+
31+
echo "Appending '${existing_cloud_logs_instance_crn}' input variable values to ${JSON_FILE}.."
32+
33+
cd "${cwd}"
34+
jq -r --arg existing_cloud_logs_instance_crn "${existing_cloud_logs_instance_crn}" \
35+
--arg existing_cloud_logs_instance_value "${existing_cloud_logs_instance_value}" \
36+
'. + {($existing_cloud_logs_instance_crn): $existing_cloud_logs_instance_value}' "${JSON_FILE}" > tmpfile && mv tmpfile "${JSON_FILE}" || exit 1
37+
38+
echo "Pre-validation completed successfully."
39+
)

0 commit comments

Comments
 (0)