Skip to content

Commit 8ab3025

Browse files
authored
ci: onboard to new catalog pipeline (#623)
1 parent 4668ac6 commit 8ab3025

12 files changed

+86
-51
lines changed

.catalog-onboard-pipeline.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
apiVersion: v1
3+
offerings:
4+
- name: deploy-arch-ibm-slz-vsi
5+
kind: solution
6+
catalog_id: 7df1e4ca-d54c-4fd0-82ce-3d13247308cd
7+
offering_id: ef663980-4c71-4fac-af4f-4a510a9bcf68
8+
variations:
9+
- name: quickstart
10+
mark_ready: false
11+
install_type: fullstack
12+
pre_validation: "tests/scripts/pre-validation-generate-ssh-key.sh ssh_key patterns/vsi-quickstart"
13+
destroy_resources_on_failure: true
14+
destroy_workspace_on_failure: false
15+
- name: standard
16+
mark_ready: false
17+
install_type: fullstack
18+
pre_validation: "tests/scripts/pre-validation-generate-ssh-key.sh ssh_public_key patterns/vsi"
19+
destroy_resources_on_failure: true
20+
destroy_workspace_on_failure: false
21+
scc:
22+
instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37
23+
region: us-south
24+
- name: deploy-arch-ibm-slz-vpc
25+
kind: solution
26+
catalog_id: 7df1e4ca-d54c-4fd0-82ce-3d13247308cd
27+
offering_id: 9fc0fa64-27af-4fed-9dce-47b3640ba739
28+
variations:
29+
- name: standard
30+
mark_ready: false
31+
install_type: fullstack
32+
destroy_resources_on_failure: true
33+
destroy_workspace_on_failure: false
34+
scc:
35+
instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37
36+
region: us-south
37+
- name: deploy-arch-ibm-slz-ocp
38+
kind: solution
39+
catalog_id: 7df1e4ca-d54c-4fd0-82ce-3d13247308cd
40+
offering_id: 95fccffc-ae3b-42df-b6d9-80be5914d852
41+
variations:
42+
- name: standard
43+
mark_ready: false
44+
install_type: fullstack
45+
destroy_resources_on_failure: true
46+
destroy_workspace_on_failure: false
47+
scc:
48+
instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37
49+
region: us-south

.releaserc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"successCmd": "echo \"SEMVER_VERSION=${nextRelease.version}\" >> $GITHUB_ENV"
1313
}],
1414
["@semantic-release/exec",{
15-
"publishCmd": "./ci/run-catalog-onboarding-pipeline.sh --version=v${nextRelease.version} --github_url=github.com --github_org=terraform-ibm-modules"
15+
"publishCmd": "./ci/trigger-catalog-onboarding-pipeline.sh --version=v${nextRelease.version}"
1616
}]
1717
]
1818
}

patterns/roks/catalogValidationValues.json.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
"region": "us-south",
44
"entitlement": "cloud_pak",
55
"tags": $TAGS,
6-
"prefix": $PREFIX
6+
"prefix": $PREFIX,
7+
"enable_transit_gateway": false,
8+
"add_atracker_route": false
79
}

patterns/vpc/catalogValidationValues.json.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
"ibmcloud_api_key": $VALIDATION_APIKEY,
33
"region": "us-east",
44
"tags": $TAGS,
5-
"prefix": $PREFIX
5+
"prefix": $PREFIX,
6+
"enable_transit_gateway": false,
7+
"add_atracker_route": false
68
}

patterns/vsi/catalogValidationValues.json.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
"ibmcloud_api_key": $VALIDATION_APIKEY,
33
"region": "eu-gb",
44
"tags": $TAGS,
5-
"prefix": $PREFIX
5+
"prefix": $PREFIX,
6+
"enable_transit_gateway": false,
7+
"add_atracker_route": false
68
}

tests/resources/main.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/resources/outputs.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/resources/variables.tf

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/resources/version.tf

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/scripts/pre-validation-generate-ssh-key.sh

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,38 @@
22

33
set -e
44

5+
USAGE="
6+
NB: This script has been designed to be run from the repos root level directroy, as that is where it will be executed from in the pre-validation stage of the catalog onboarding pipeline.
7+
8+
The script will generate SSH keys and then append the public key to the catalogValidationValues.json file which is generated by the onboarding catalog pipeline before this script runs.
9+
10+
Usage (from repos root directory): ./tests/scripts/pre-validation-generate-ssh-key.sh <ssh_key_variable_name> <directory_of_json>
11+
12+
where:
13+
<ssh_key_variable_name> = The name of the terraform variable which takes the SSH public key as input
14+
<directory_of_json> = The directory where the catalogValidationValues.json file exists (will be the same directroy as the terraform code being onboarded)
15+
"
16+
517
if [ $# -eq 0 ]; then
6-
echo "No arguments supplied - expected the terraform input variable name for ssh public key"
18+
echo "No arguments supplied. See usage:"
19+
echo "${USAGE}"
720
exit 1
821
fi
922

10-
var_name=$1
11-
12-
# Paths relative to base directory of script
13-
BASE_DIR=$(dirname "$0")
14-
TERRAFORM_SOURCE_DIR="../resources"
15-
JSON_FILE="../../../catalogValidationValues.json"
23+
VAR_NAME=$1
24+
DIR=$2
1625

17-
(
18-
# Execute script from base directory
19-
cd "${BASE_DIR}"
20-
echo "Generating SSH public key to be used for validation .."
26+
# Generate SSH keys and place in temp directory
27+
temp_dir=$(mktemp -d)
28+
ssh-keygen -f "${temp_dir}/id_rsa" -t rsa -N '' <<<y
2129

22-
cd ${TERRAFORM_SOURCE_DIR}
23-
terraform init || exit 1
24-
terraform apply -auto-approve || exit 1
30+
# Extract public key value and delete temp directory
31+
ssh_public_key=$(cat "${temp_dir}/id_rsa.pub")
32+
rm -rf "${temp_dir}"
2533

26-
ssh_public_key=$(terraform output -state=terraform.tfstate -raw ssh_public_key)
27-
echo "Appending SSH public key to $(basename ${JSON_FILE}).."
28-
jq -r --arg var_name "${var_name}" --arg ssh_public_key "${ssh_public_key}" '. + {($var_name): $ssh_public_key}' "${JSON_FILE}" > tmpfile && mv tmpfile "${JSON_FILE}" || exit 1
34+
# Append the SSH public key value to the JSON file which will be used during catalog onboarding validation
35+
json_file="${DIR}/catalogValidationValues.json" # This gets created by pipeline code based on the catalogValidationValues.json.template
36+
echo "Appending SSH public key to ${json_file}.."
37+
jq -r --arg var_name "${VAR_NAME}" --arg ssh_public_key "${ssh_public_key}" '. + {($var_name): $ssh_public_key}' "${json_file}" > tmpfile && mv tmpfile "${json_file}" || exit 1
2938

30-
echo "Pre-validation complete successfully"
31-
)
39+
echo "Pre-validation complete successfully"

0 commit comments

Comments
 (0)