generated from dxw/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update qa deploy to enable static routes
- Loading branch information
Showing
7 changed files
with
89 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
cf login -u $CF_USER -p $CF_PASSWORD -a https://api.london.cloud.service.gov.uk -s $TF_VAR_cloudfoundry_space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
static_route_base=ghbs-qa | ||
app_name=$1 | ||
IFS=$'\n' all_web_apps=($(cf apps | sed -e "1,/^name/d" | awk '{print $1}' | grep -v "worker")) | ||
|
||
# initialize list of static route usage statuses (15 routes) | ||
static_routes=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) | ||
|
||
function getStaticRouteForApp() | ||
{ | ||
route_for_current_app=$(cf app $1 | grep 'routes:' | cut -d ':' -f 2 | tr "," "\\n" | grep $static_route_base | cut -d '.' -f 1) | ||
|
||
if [[ $route_for_current_app != "" ]]; then | ||
echo $route_for_current_app | ||
fi | ||
} | ||
|
||
# if app already exists | ||
if [[ $(echo $all_web_apps | grep $app_name) != "" ]]; then | ||
# check if this app already has a route | ||
static_route=$(getStaticRouteForApp $app_name) | ||
|
||
if [[ $static_route != "" ]]; then | ||
echo $static_route | ||
exit 0 | ||
fi | ||
fi | ||
|
||
# detect which routes are currently being used | ||
for current_app in "${all_web_apps[@]}"; do | ||
static_route=$(getStaticRouteForApp $current_app) | ||
|
||
if [[ $static_route != "" ]]; then | ||
enabled_route_number=$(echo $static_route | rev | cut -d '-' -f '1' | rev) | ||
static_routes[$enabled_route_number]=1 | ||
fi | ||
done | ||
|
||
# get the first one | ||
for i in "${!static_routes[@]}"; do | ||
if [[ "${static_routes[i]}" == 0 ]]; then | ||
echo "$static_route_base-$((i+1))" | ||
exit 0 | ||
fi | ||
done | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Map the QA static route to the instance | ||
|
||
# wait for app to become started | ||
until cf app $CF_APP_NAME | grep "requested state:" | grep started | ||
do | ||
echo "Waiting for app to start..." | ||
sleep 2 | ||
done | ||
|
||
sleep 10 | ||
|
||
# Now we can safely map the routes | ||
|
||
cf map-route $CF_APP_NAME london.cloudapps.digital --hostname $STATIC_ROUTE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters