adding some validation for gcloud beta and instance exits
This commit is contained in:
22
Makefile
22
Makefile
@@ -382,7 +382,27 @@ dataconnect-sync:
|
||||
# This should only be executed when setting up a brand new environment
|
||||
# (e.g., first-time dev setup or new GCP project).
|
||||
# -------------------------------------------------------------------
|
||||
dataconnect-bootstrap-db:
|
||||
|
||||
# Comprueba que gcloud y el grupo beta están disponibles
|
||||
check-gcloud-beta:
|
||||
@command -v gcloud >/dev/null 2>&1 || { \
|
||||
echo "❌ gcloud CLI not found. Please install it: https://cloud.google.com/sdk/docs/install"; \
|
||||
exit 1; \
|
||||
}
|
||||
@gcloud beta --help >/dev/null 2>&1 || { \
|
||||
echo "❌ 'gcloud beta' is not available. Run 'gcloud components update' or reinstall the SDK."; \
|
||||
exit 1; \
|
||||
}
|
||||
@echo "✅ gcloud CLI and 'gcloud beta' are available."
|
||||
|
||||
dataconnect-bootstrap-db: check-gcloud-beta
|
||||
@echo "🔍 Checking if Cloud SQL instance krow-sql already exists in [$(GCP_PROJECT_ID)]..."
|
||||
@if gcloud sql instances describe krow-sql --project=$(GCP_PROJECT_ID) >/dev/null 2>&1; then \
|
||||
echo "⚠️ Cloud SQL instance 'krow-sql' already exists in project $(GCP_PROJECT_ID)."; \
|
||||
echo " If you really need to recreate it, delete the instance manually first."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
@echo "⚠️ Creating Cloud SQL instance krow-sql (tier: $(SQL_TIER)) (ONLY RUN THIS ONCE PER PROJECT)..."
|
||||
gcloud sql instances create krow-sql \
|
||||
--database-version=POSTGRES_15 \
|
||||
|
||||
Reference in New Issue
Block a user