Skip to content

Commit

Permalink
fix: the issue with gcloud list output
Browse files Browse the repository at this point in the history
  • Loading branch information
Shabirmean committed Oct 27, 2021
1 parent 36f3508 commit 0076892
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions extras/cloudsql/create_cloudsql_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ echo "☁️ Enabling the Cloud SQL API..."
gcloud config set project ${PROJECT_ID}
gcloud services enable sqladmin.googleapis.com

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

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

# Create Ledger DB
LEDGER_DB_EXISTS=$(gcloud sql databases list --instance=${INSTANCE_NAME} --filter="ledger-db")
if [ $LEDGER_DB_EXISTS = "Listed 0 items." ]; then
LEDGER_DB_EXISTS=$(gcloud sql databases list --instance=${INSTANCE_NAME} --filter="ledger-db" | wc -l)
if [ $LEDGER_DB_EXISTS = "0" ]; then
echo "☁️ Creating ledger-db in ${INSTANCE_NAME}..."
gcloud sql databases create ledger-db --instance=$INSTANCE_NAME
fi
Expand Down
4 changes: 2 additions & 2 deletions extras/cloudsql/setup_workload_identity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ kubectl create namespace $NAMESPACE
echo "✅ Creating GCP and K8s service accounts..."
kubectl create serviceaccount --namespace $NAMESPACE $KSA_NAME

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

Expand Down

0 comments on commit 0076892

Please sign in to comment.