-
Notifications
You must be signed in to change notification settings - Fork 373
Expand file tree
/
Copy pathdelete-app.sh
More file actions
executable file
·36 lines (29 loc) · 1.2 KB
/
delete-app.sh
File metadata and controls
executable file
·36 lines (29 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Script to delete a Control Plane application
# Required environment variables:
# - APP_NAME: Name of the application to delete
# - CPLN_ORG: Organization name
set -e
# Validate required environment variables
: "${APP_NAME:?APP_NAME environment variable is required}"
: "${CPLN_ORG:?CPLN_ORG environment variable is required}"
# Safety check: prevent deletion of production or staging apps
if echo "$APP_NAME" | grep -iqE '(production|staging)'; then
echo "❌ ERROR: Cannot delete apps containing 'production' or 'staging' in their name" >&2
echo "🛑 This is a safety measure to prevent accidental deletion of production or staging environments" >&2
echo " App name: $APP_NAME" >&2
exit 1
fi
# Check if app exists before attempting to delete
echo "🔍 Checking if application exists: $APP_NAME"
if ! cpflow exists -a "$APP_NAME" --org "$CPLN_ORG"; then
echo "⚠️ Application does not exist: $APP_NAME"
exit 0
fi
# Delete the application
echo "🗑️ Deleting application: $APP_NAME"
if ! cpflow delete -a "$APP_NAME" --org "$CPLN_ORG" --force; then
echo "❌ Failed to delete application: $APP_NAME" >&2
exit 1
fi
echo "✅ Successfully deleted application: $APP_NAME"