mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #1013 from lmars/fix-urls
Fix URL schemes in `dokku urls` output
This commit is contained in:
@@ -153,24 +153,27 @@ case "$1" in
|
||||
url | urls)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
APP="$2"; SCHEME="http"; SSL="$DOKKU_ROOT/$APP/tls"; WILDCARD_SSL="$DOKKU_ROOT/tls"
|
||||
APP="$2";
|
||||
|
||||
if [[ -s "$DOKKU_ROOT/$APP/URLS" ]]; then
|
||||
case "$1" in
|
||||
url)
|
||||
grep "^http" "$DOKKU_ROOT/$APP/URLS" | head -1
|
||||
;;
|
||||
urls)
|
||||
grep "^http" "$DOKKU_ROOT/$APP/URLS"
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCHEME="http"; SSL="$DOKKU_ROOT/$APP/tls"; WILDCARD_SSL="$DOKKU_ROOT/tls"
|
||||
if [[ -e "$SSL/server.crt" && -e "$SSL/server.key" ]] || [[ -e "$WILDCARD_SSL/server.crt" && -e "$WILDCARD_SSL/server.key" ]]; then
|
||||
SCHEME="https"
|
||||
fi
|
||||
|
||||
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
|
||||
case "$1" in
|
||||
url)
|
||||
echo "$SCHEME://$(head -n1 "$DOKKU_ROOT/$APP/VHOST")"
|
||||
;;
|
||||
urls)
|
||||
for vhost in $(< "$DOKKU_ROOT/$APP/VHOST"); do
|
||||
echo "$SCHEME://$vhost"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
elif [[ -f "$DOKKU_ROOT/VHOST" ]]; then
|
||||
if [[ -f "$DOKKU_ROOT/VHOST" ]]; then
|
||||
echo "$SCHEME://$(< "$DOKKU_ROOT/VHOST")"
|
||||
else
|
||||
echo "$SCHEME://$(< "$DOKKU_ROOT/HOSTNAME"):$(< "$DOKKU_ROOT/$APP/PORT")"
|
||||
|
||||
@@ -18,6 +18,7 @@ case "$1" in
|
||||
nginx:build-config)
|
||||
APP="$2"; DOKKU_APP_LISTEN_PORT="$3"; DOKKU_APP_LISTEN_IP="${4}"
|
||||
VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
URLS_PATH="$DOKKU_ROOT/$APP/URLS"
|
||||
WILDCARD_SSL="$DOKKU_ROOT/tls"
|
||||
SSL="$DOKKU_ROOT/$APP/tls"
|
||||
|
||||
@@ -99,6 +100,10 @@ EOF
|
||||
echo " Reloading nginx"
|
||||
restart_nginx
|
||||
fi
|
||||
|
||||
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" > $URLS_PATH
|
||||
xargs -i echo "https://{}" <<< "${SSL_VHOSTS}" >> $URLS_PATH
|
||||
xargs -i echo "http://{}" <<< "${NONSSL_VHOSTS}" >> $URLS_PATH
|
||||
else
|
||||
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
|
||||
dokku_log_info1 "VHOST support disabled, deleting $APP/VHOST"
|
||||
|
||||
@@ -12,6 +12,20 @@ teardown() {
|
||||
disable_tls_wildcard
|
||||
}
|
||||
|
||||
assert_urls() {
|
||||
urls=$@
|
||||
run dokku urls $TEST_APP
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output < <(tr ' ' '\n' <<< "${urls}")
|
||||
}
|
||||
|
||||
build_nginx_config() {
|
||||
# simulate nginx post-deploy
|
||||
dokku domains:setup $TEST_APP
|
||||
dokku nginx:build-config $TEST_APP
|
||||
}
|
||||
|
||||
@test "run (with tty)" {
|
||||
deploy_app
|
||||
run /bin/bash -c "dokku run $TEST_APP ls /app/package.json"
|
||||
@@ -37,24 +51,29 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "urls (non-ssl)" {
|
||||
run bash -c "dokku urls $TEST_APP | grep dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "http://dokku.me"
|
||||
assert_urls "http://dokku.me"
|
||||
build_nginx_config
|
||||
assert_urls "http://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
|
||||
}
|
||||
|
||||
@test "urls (app ssl)" {
|
||||
setup_test_tls
|
||||
run bash -c "dokku urls $TEST_APP | grep dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "https://dokku.me"
|
||||
assert_urls "https://dokku.me"
|
||||
build_nginx_config
|
||||
assert_urls "https://node-js-app.dokku.me" "http://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
assert_urls "https://node-js-app.dokku.me" "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
|
||||
}
|
||||
|
||||
@test "urls (wildcard ssl)" {
|
||||
setup_test_tls_wildcard
|
||||
run bash -c "dokku urls $TEST_APP | grep dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output "https://dokku.me"
|
||||
assert_urls "https://dokku.me"
|
||||
build_nginx_config
|
||||
assert_urls "https://${TEST_APP}.dokku.me"
|
||||
add_domain "test.dokku.me"
|
||||
assert_urls "https://${TEST_APP}.dokku.me" "https://test.dokku.me"
|
||||
add_domain "dokku.example.com"
|
||||
assert_urls "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://dokku.example.com"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user