Skip to content

Commit

Permalink
Merge pull request #150 from mwringe/validate_hostname
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Jun 27, 2016
2 parents d83cd63 + 46b6274 commit d86d766
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions deployer/scripts/hawkular.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ EOF
route_params="${route_params} --ca-cert=${secret_dir}/hawkular-metrics-ca.cert"
fi
fi
# this may return an error code if the route already exists, this is to be expect with a refresh and is why we have the || true here
oc create route reencrypt hawkular-metrics ${route_params} || true
if [ "${use_persistent_storage}" = true ]; then
Expand Down
16 changes: 15 additions & 1 deletion deployer/scripts/preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ function validate_master_accessible() {
return 1
}

function validate_hostname() {
#The route will only accept RFC 952 based hostnames
if [[ $hawkular_metrics_hostname =~ ^[a-zA-Z][a-zA-Z0-9.-]?+[a-zA-Z0-9]$ ]]; then
echo "The HAWKULAR_METRICS_HOSTNAME value is deemed acceptable."
return 0
else
echo "The HAWKULAR_METRICS_HOSTNAME value must be a valid hostname (RFC 952)"
echo "The value which was specified is invalid:"
echo " $hawkular_metrics_hostname"
echo "Hostnames must start with a letter, may only contain letters, numbers, '.' and '-'."
return 1
fi
}

function cert_should_have_names() {
local file="$1"; shift
local output name cn san sans found count
Expand Down Expand Up @@ -112,7 +126,7 @@ function validate_preflight() {

local success=()
local failure=()
for func in validate_master_accessible validate_deployer_secret; do
for func in validate_master_accessible validate_hostname validate_deployer_secret; do
func_output="$($func 2>&1)" && \
success+=("$func: $func_output") || \
failure+=("$func: "$'\n'"$func_output")
Expand Down
2 changes: 1 addition & 1 deletion hack/tests/ci_test_every_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ TEST_PERF=${TEST_PERF:-false}
for lib in "${OS_ROOT}"/hack/{util.sh,text.sh} \
"${OS_ROOT}"/hack/lib/*.sh "${OS_ROOT}"/hack/lib/**/*.sh
do source "$lib"; done
os::log::install_errexit
os::log::stacktrace::install

os::util::environment::setup_time_vars

Expand Down

0 comments on commit d86d766

Please sign in to comment.