Skip to content

Commit

Permalink
Add pre-start script to fail fast when app and system domains overlap
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Saxby <esaxby@pivotal.io>
  • Loading branch information
petergtz committed Apr 14, 2016
1 parent 34e847e commit 222711a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jobs/cloud_controller_ng/spec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ templates:
dea_ca.crt.erb: config/certs/dea_ca.crt
dea_client.crt.erb: config/certs/dea_client.crt
dea_client.key.erb: config/certs/dea_client.key
pre-start.sh.erb: bin/pre-start
check_for_domain_overlap.sh: bin/check_for_domain_overlap.sh

packages:
- capi_utils
Expand Down
16 changes: 16 additions & 0 deletions jobs/cloud_controller_ng/templates/check_for_domain_overlap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash


function check_for_domain_overlap {
system_domain=$1
shift
app_domains=($@)

for app_domain in "${app_domains[@]}"; do
if [[ $app_domain == *$system_domain ]]; then
echo "Invalid configuration: app_domains contains the value ${app_domain} which is a sub-domain of the system_domain, ${system_domain}."
return 1
fi
done
}

10 changes: 10 additions & 0 deletions jobs/cloud_controller_ng/templates/pre-start.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
source "${SCRIPT_DIR}/check_for_domain_overlap.sh"

app_domains=(<%= p('app_domains').join(' ') %>)
system_domain=<%= p('system_domain') %>

check_for_domain_overlap $system_domain ${app_domains[@]}
exit $?

0 comments on commit 222711a

Please sign in to comment.