-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdestroy.sh
More file actions
executable file
·63 lines (45 loc) · 1.74 KB
/
destroy.sh
File metadata and controls
executable file
·63 lines (45 loc) · 1.74 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -e
CWD=$1
CLOUD=$2
echo "#################################################################################"
echo "ALL RESOURCES deployed as part of $CWD module will deleted "
echo "This operation CANNOT be undone. "
echo "##################################################################################"
read -p "Do you wish to continue? (y/n): " answer
if [[ "$answer" =~ ^([yY][eE][sS]|[yY])$ ]]; then
if [[ "$CWD" == "core" ]]; then
echo "Checking for dependencies"
find modules -type d | while read -r dir; do
if [[ "$(basename "$dir")" == "core" ]]; then
continue
fi
if [[ -e "$dir/.deployed" ]]; then
echo "🚫 Deployment exist in $dir. Cannot remove core module"
exit 1
fi
done
echo "Dependency check complete"
fi
cd modules/$CWD
chmod +x destroy.sh
./destroy.sh $CLOUD
echo " "
if [[ "$CWD" != "core" ]]; then
cd ../core
EXTRA_PARAMS_CLOUD=$(paste -sd, "../../$CLOUD.env")
EXTRA_PARAMS_GENERAL=$(paste -sd, "../../application.env")
EXTRA_PARAMS="$EXTRA_PARAMS_GENERAL,$EXTRA_PARAMS_CLOUD"
if [[ -f "module.env" ]]; then
EXTRA_PARAMS_MODULE=$(paste -sd, "module.env")
EXTRA_PARAMS="$EXTRA_PARAMS,$EXTRA_PARAMS_MODULE"
fi
user_email=$(databricks current-user me | jq '.emails[0].value' | tr -d '"')
echo "⏩️ Running job to delete all endpoints and archive the inference tables"
databricks bundle run --params "module=$CWD,destroy_user_email=$user_email" destroy_module_job --var="$EXTRA_PARAMS"
cd ../..
fi
else
echo "Aborted."
exit 1
fi