Skip to content

Commit f313008

Browse files
authored
fix: updated DA validation to include KMS (#154)
1 parent 0067fb4 commit f313008

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
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-validate.sh"
13+
post_validation: "tests/scripts/post-validate.sh"
1214
scc:
1315
instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37
1416
region: us-south

solutions/fully-configurable/catalogValidationValues.json.template

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
"prefix": $PREFIX,
44
"region": "us-south",
55
"resource_tags": $TAGS,
6-
"existing_resource_group_name": "geretain-test-resources",
7-
"existing_cos_instance_crn": $COS_INSTANCE_CRN,
8-
"enable_cos_kms_encryption": false
6+
"enable_cos_kms_encryption": true
97
}

tests/scripts/post-validate.sh

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 prerequisite resource required for catalog validation ##
5+
## (required as temporary workaround for issue https://github.ibm.com/GoldenEye/issues/issues/15533) ##
6+
########################################################################################################################
7+
8+
set -e
9+
10+
TERRAFORM_SOURCE_DIR="tests/resources/kp-cos-instance"
11+
TF_VARS_FILE="terraform.tfvars"
12+
13+
(
14+
cd ${TERRAFORM_SOURCE_DIR}
15+
echo "Destroying resource group and cos instance.."
16+
terraform destroy -input=false -auto-approve -var-file=${TF_VARS_FILE} || exit 1
17+
rm -f "${TF_VARS_FILE}"
18+
19+
echo "Post-validation completed successfully"
20+
)

tests/scripts/pre-validate.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#! /bin/bash
2+
3+
############################################################################################################
4+
## This script is used by the catalog pipeline to provision a new resource group and cos instance
5+
## (required as temporary workaround for issue https://github.ibm.com/GoldenEye/issues/issues/15533)
6+
############################################################################################################
7+
8+
set -e
9+
10+
DA_DIR="solutions/fully-configurable"
11+
TERRAFORM_SOURCE_DIR="tests/resources/kp-cos-instance"
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 new resource group, kms instance and cos instance .."
19+
terraform init || exit 1
20+
# $VALIDATION_APIKEY is available in the catalog runtime
21+
{
22+
echo "ibmcloud_api_key=\"${VALIDATION_APIKEY}\""
23+
echo "prefix=\"wxai-$(openssl rand -hex 2)\""
24+
echo "region=\"us-south\""
25+
} >> ${TF_VARS_FILE}
26+
terraform apply -input=false -auto-approve -var-file=${TF_VARS_FILE} || exit 1
27+
28+
cos_var_name="existing_cos_instance_crn"
29+
cos_value=$(terraform output -state=terraform.tfstate -raw cos_crn)
30+
kms_var_name="existing_kms_instance_crn"
31+
kms_value=$(terraform output -state=terraform.tfstate -raw key_protect_crn)
32+
rg_var_name="existing_resource_group_name"
33+
rg_value=$(terraform output -state=terraform.tfstate -raw resource_group_name)
34+
35+
echo "Appending '${cos_var_name}' and '${kms_var_name}', input variables to ${JSON_FILE}.."
36+
37+
cd "${cwd}"
38+
jq -r --arg cos_var_name "${cos_var_name}" \
39+
--arg cos_value "${cos_value}" \
40+
'. + {($cos_var_name): $cos_value}' "${JSON_FILE}" > tmpfile && mv tmpfile "${JSON_FILE}" || exit 1
41+
jq -r --arg kms_var_name "${kms_var_name}" \
42+
--arg kms_value "${kms_value}" \
43+
'. + {($kms_var_name): $kms_value}' "${JSON_FILE}" > tmpfile && mv tmpfile "${JSON_FILE}" || exit 1
44+
jq -r --arg rg_var_name "${rg_var_name}" \
45+
--arg rg_value "${rg_value}" \
46+
'. + {($rg_var_name): $rg_value}' "${JSON_FILE}" > tmpfile && mv tmpfile "${JSON_FILE}" || exit 1
47+
48+
echo "Pre-validation complete successfully"
49+
)

0 commit comments

Comments
 (0)