Skip to content

Commit 93a1766

Browse files
committed
feat: more inputs
1 parent 09179ce commit 93a1766

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.def.json

deploy-many.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
PROJECT_ID="bdad81fb-e28b-4ce7-aea4-72ab81c8718d"
6+
CONFIG_IDS=("64271bc0-c3b6-4828-b7b5-b6024d9e3598")
7+
8+
function validate_config() {
9+
ibmcloud project config-validate --project-id $PROJECT_ID --id $CONFIG_ID --output json > /tmp/validation.json
10+
}
11+
12+
function wait_for_validation() {
13+
# Loop until the state is set to validated
14+
while true; do
15+
16+
# Get the current state of the configuration
17+
STATE=$(ibmcloud project config --project-id $PROJECT_ID --id $CONFIG_ID --output json | jq -r '.state')
18+
19+
if [[ "$STATE" == "validated" ]]; then
20+
break
21+
fi
22+
23+
if [[ "$STATE" != "validating" ]]; then
24+
echo "Error: Unexpected state $STATE"
25+
exit 1
26+
fi
27+
28+
sleep 10
29+
done
30+
}
31+
32+
function approve_config() {
33+
ibmcloud project config-approve --project-id $PROJECT_ID --id $CONFIG_ID --comment "I approve through CLI"
34+
}
35+
36+
function deploy_config() {
37+
ibmcloud project config-deploy --project-id $PROJECT_ID --id $CONFIG_ID
38+
}
39+
40+
function wait_for_deployment() {
41+
while true; do
42+
# Retrieve the configuration
43+
RESPONSE=$(ibmcloud project config --project-id $PROJECT_ID --id $CONFIG_ID --output json)
44+
45+
# Check the state of the configuration under approved_version
46+
STATE=$(echo "$RESPONSE" | jq -r ".approved_version.state")
47+
48+
# If the state is "deployed" or "deploying_failed", exit the loop
49+
if [[ "$STATE" == "deployed" || "$STATE" == "deploying_failed" ]]; then
50+
break
51+
fi
52+
53+
# If the state is not "deploying", print an error message and exit
54+
if [[ "$STATE" != "deploying" ]]; then
55+
echo "Error: Unexpected state $STATE"
56+
exit 1
57+
fi
58+
59+
# Sleep for a few seconds before checking the state again
60+
sleep 10
61+
done
62+
}
63+
64+
# 6. Loop through the configuration IDs and execute the functions
65+
for CONFIG_ID in "${CONFIG_IDS[@]}"
66+
do
67+
validate_config
68+
wait_for_validation
69+
approve_config
70+
deploy_config
71+
wait_for_deployment
72+
done

stack_definition.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
{
4242
"name": "region",
4343
"value": "ref:../../inputs/region"
44-
},
45-
{
46-
"name": "resource_group_name",
47-
"value": "ref:../../inputs/resource_group_name"
4844
}
4945
],
5046
"name": "1 - Account Infrastructure Base",

0 commit comments

Comments
 (0)