Skip to content

Commit 63d7f5e

Browse files
authored
fix: fallback to name if location is not set (terraform-google-modules#736)
1 parent 6682911 commit 63d7f5e

File tree

8 files changed

+48
-8
lines changed

8 files changed

+48
-8
lines changed

autogen/main/scripts/wait-for-cluster.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4
2828
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2929

3030
while
31-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
# if cluster location is set, use it in filter
32+
if [ -z "${CLUSTER_LOCATION}" ]; then
33+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
34+
else
35+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
36+
fi
3237
if [ -z "${current_status}" ]; then
3338
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
3439
exit 1

modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4
2828
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2929

3030
while
31-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
# if cluster location is set, use it in filter
32+
if [ -z "${CLUSTER_LOCATION}" ]; then
33+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
34+
else
35+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
36+
fi
3237
if [ -z "${current_status}" ]; then
3338
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
3439
exit 1

modules/beta-private-cluster/scripts/wait-for-cluster.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4
2828
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2929

3030
while
31-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
# if cluster location is set, use it in filter
32+
if [ -z "${CLUSTER_LOCATION}" ]; then
33+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
34+
else
35+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
36+
fi
3237
if [ -z "${current_status}" ]; then
3338
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
3439
exit 1

modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4
2828
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2929

3030
while
31-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
# if cluster location is set, use it in filter
32+
if [ -z "${CLUSTER_LOCATION}" ]; then
33+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
34+
else
35+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
36+
fi
3237
if [ -z "${current_status}" ]; then
3338
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
3439
exit 1

modules/beta-public-cluster/scripts/wait-for-cluster.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4
2828
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2929

3030
while
31-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
# if cluster location is set, use it in filter
32+
if [ -z "${CLUSTER_LOCATION}" ]; then
33+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
34+
else
35+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
36+
fi
3237
if [ -z "${current_status}" ]; then
3338
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
3439
exit 1

modules/private-cluster-update-variant/scripts/wait-for-cluster.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4
2828
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2929

3030
while
31-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
# if cluster location is set, use it in filter
32+
if [ -z "${CLUSTER_LOCATION}" ]; then
33+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
34+
else
35+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
36+
fi
3237
if [ -z "${current_status}" ]; then
3338
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
3439
exit 1

modules/private-cluster/scripts/wait-for-cluster.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4
2828
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2929

3030
while
31-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
# if cluster location is set, use it in filter
32+
if [ -z "${CLUSTER_LOCATION}" ]; then
33+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
34+
else
35+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
36+
fi
3237
if [ -z "${current_status}" ]; then
3338
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
3439
exit 1

scripts/wait-for-cluster.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4
2828
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2929

3030
while
31-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
# if cluster location is set, use it in filter
32+
if [ -z "${CLUSTER_LOCATION}" ]; then
33+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
34+
else
35+
current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
36+
fi
3237
if [ -z "${current_status}" ]; then
3338
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
3439
exit 1

0 commit comments

Comments
 (0)