Skip to content

Commit 0076892

Browse files
committed
fix: the issue with gcloud list output
1 parent 36f3508 commit 0076892

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

extras/cloudsql/create_cloudsql_instance.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ echo "☁️ Enabling the Cloud SQL API..."
1919
gcloud config set project ${PROJECT_ID}
2020
gcloud services enable sqladmin.googleapis.com
2121

22-
CSQL_EXISTS=$(gcloud sql instances list --filter="${INSTANCE_NAME}")
23-
if [ $CSQL_EXISTS = "Listed 0 items." ]; then
22+
CSQL_EXISTS=$(gcloud sql instances list --filter="${INSTANCE_NAME}" | wc -l)
23+
if [ $CSQL_EXISTS = "0" ]; then
2424
echo "☁️ Creating Cloud SQL instance: ${INSTANCE_NAME} ..."
2525
gcloud sql instances create $INSTANCE_NAME \
2626
--database-version=POSTGRES_12 --tier=db-custom-1-3840 \
@@ -35,15 +35,15 @@ gcloud sql users create admin \
3535
--instance=$INSTANCE_NAME --password=admin
3636

3737
# Create Accounts DB
38-
ACCOUNTS_DB_EXISTS=$(gcloud sql databases list --instance=${INSTANCE_NAME} --filter="accounts-db")
39-
if [ $ACCOUNTS_DB_EXISTS = "Listed 0 items." ]; then
38+
ACCOUNTS_DB_EXISTS=$(gcloud sql databases list --instance=${INSTANCE_NAME} --filter="accounts-db" | wc -l)
39+
if [ $ACCOUNTS_DB_EXISTS = "0" ]; then
4040
echo "☁️ Creating accounts-db in ${INSTANCE_NAME}..."
4141
gcloud sql databases create accounts-db --instance=$INSTANCE_NAME
4242
fi
4343

4444
# Create Ledger DB
45-
LEDGER_DB_EXISTS=$(gcloud sql databases list --instance=${INSTANCE_NAME} --filter="ledger-db")
46-
if [ $LEDGER_DB_EXISTS = "Listed 0 items." ]; then
45+
LEDGER_DB_EXISTS=$(gcloud sql databases list --instance=${INSTANCE_NAME} --filter="ledger-db" | wc -l)
46+
if [ $LEDGER_DB_EXISTS = "0" ]; then
4747
echo "☁️ Creating ledger-db in ${INSTANCE_NAME}..."
4848
gcloud sql databases create ledger-db --instance=$INSTANCE_NAME
4949
fi

extras/cloudsql/setup_workload_identity.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ kubectl create namespace $NAMESPACE
2626
echo "✅ Creating GCP and K8s service accounts..."
2727
kubectl create serviceaccount --namespace $NAMESPACE $KSA_NAME
2828

29-
SA_EXISTS=$(gcloud iam service-accounts list --filter="${GSA_NAME}")
30-
if [ $SA_EXISTS = "Listed 0 items." ]; then
29+
SA_EXISTS=$(gcloud iam service-accounts list --filter="${GSA_NAME}" | wc -l)
30+
if [ $SA_EXISTS = "0" ]; then
3131
gcloud iam service-accounts create $GSA_NAME
3232
fi
3333

0 commit comments

Comments
 (0)