From 3a1f2d59475588a1d80ffbc41057eb80ae42e6a6 Mon Sep 17 00:00:00 2001 From: Vedant Pareek Date: Thu, 19 Dec 2024 23:49:30 +0530 Subject: [PATCH] fixing handle error logic to properly terminate --- scripts/setup_truefoundry_cluster.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/setup_truefoundry_cluster.sh b/scripts/setup_truefoundry_cluster.sh index 7d93f46..512f174 100755 --- a/scripts/setup_truefoundry_cluster.sh +++ b/scripts/setup_truefoundry_cluster.sh @@ -93,15 +93,18 @@ function create_cluster() { local manifest=$(echo "$CLUSTER_CONFIG_BASE64" | base64 -d) - log_info "create_cluster:: cluster manifest ${manifest}" + log_info "create_cluster: cluster manifest ${manifest}" local response=$(make_request "PUT" "${CONTROL_PLANE_URL}/api/svc/v1/cluster/" "${manifest}" "200,201") || \ handle_error "create_cluster: Failed to create cluster" + log_info "create_cluster: Response $response" + local cluster_id=$(echo "${response}" | jq -r '.id') || \ handle_error "create_cluster: Failed to parse cluster response" + + log_info "create_cluster: Cluster ID $cluster_id" - [ -z "${cluster_id}" ] || [ "${cluster_id}" = "null" ] || \ - handle_error "create_cluster: No cluster ID found in response" + [ -z "${cluster_id}" ] && handle_error "create_cluster: No cluster ID found in response" && return 1 echo "${cluster_id}" } @@ -117,8 +120,7 @@ function get_cluster_token() { local token=$(echo "${response}" | jq -r '.clusterToken') || \ handle_error "Failed to parse cluster token response" - [ -z "${token}" ] || [ "${token}" = "null" ] && \ - handle_error "No cluster token found in response" + [ -z "${token}" ] && handle_error "No cluster token found in response" && return 1 echo "${token}" }