Skip to content

Commit 7b25e7f

Browse files
committed
chore: add log in create_qovery_demo.sh script
1 parent b2b9df1 commit 7b25e7f

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

cmd/demo_scripts/create_qovery_demo.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,28 @@ get_or_create_demo_cluster() {
4747
if [ "$clusterId" = "" ]
4848
then
4949
payload='{"name":"'$2'","region":"on-premise","cloud_provider":"ON_PREMISE","kubernetes":"SELF_MANAGED", "production": false, "is_demo": true, "features":[],"cloud_provider_credentials":{"cloud_provider":"ON_PREMISE","credentials":{"id":"'${accountId}'","name":"on-premise"},"region":"unknown"}}'
50-
clusterId=$(curl -s -X POST --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' -H "User-Agent: ${USER_AGENT}" -d "${payload}" ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/cluster | jq -r .id)
51-
fi
5250

53-
echo "$clusterId"
51+
post_response=$(curl -s -X POST -w "\n%{http_code}" --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' -H "User-Agent: ${USER_AGENT}" -d "${payload}" ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/cluster)
52+
53+
response_body=$(echo "$post_response" | sed '$d')
54+
status_code=$(echo "$post_response" | tail -n 1)
55+
56+
if [ "$status_code" != "201" ]; then
57+
echo "❌ Failed to create demo cluster '$clusterName'. Status code: $status_code" >&2
58+
echo "Response: $response_body" >&2
59+
exit 1
60+
fi
61+
62+
clusterId=$(echo "$response_body" | jq -r .id)
63+
64+
if [ "$clusterId" = "null" ] || [ -z "$clusterId" ]; then
65+
echo "❌ Failed to extract cluster ID from response" >&2
66+
echo "Response: $response_body" >&2
67+
exit 1
68+
fi
69+
fi
70+
71+
echo "$clusterId"
5472
}
5573

5674
get_cluster_values() {

0 commit comments

Comments
 (0)