From 0147d55302bb6f7258fdf57319c378d025a1713f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 17 Jul 2017 00:30:35 -0600 Subject: [PATCH 1/4] fix: skip clearing cache if we are not building a herokuish image Closes #2771 --- plugins/apps/pre-delete | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/apps/pre-delete b/plugins/apps/pre-delete index d1fc39ed5..8fe4e5fe2 100755 --- a/plugins/apps/pre-delete +++ b/plugins/apps/pre-delete @@ -8,6 +8,10 @@ apps_pre_delete() { local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG"); local CACHE_DIR="$DOKKU_ROOT/$APP/cache" verify_app_name "$APP" + if ! is_image_herokuish_based "$IMAGE"; then + return + fi + if [[ -d $CACHE_DIR ]]; then docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$CACHE_DIR:/cache" "$IMAGE" find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; || true fi From 5af42dc678908881e6d6a3a8fda6b6f61f51af81 Mon Sep 17 00:00:00 2001 From: Domonkos Czinke Date: Tue, 5 Jul 2016 21:53:54 +0200 Subject: [PATCH 2/4] url command should return https if it's configured --- plugins/common/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/common/functions b/plugins/common/functions index b7e586381..2781e0604 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -1015,7 +1015,7 @@ get_app_urls() { local URLS="$(merge_dedupe_list "$port_urls $app_urls" " ")" case "$1" in url) - echo "$URLS" | tr ' ' '\n' | head -n1 + echo "$URLS" | tr ' ' '\n' | tail -1 ;; urls) echo "$URLS" | tr ' ' '\n' | sort From 0efb69099269dafd97f350e0caf6e4d472ae5363 Mon Sep 17 00:00:00 2001 From: Domonkos Czinke Date: Mon, 11 Jul 2016 15:41:05 +0200 Subject: [PATCH 3/4] Fix URL error and add test --- plugins/common/functions | 9 +++++++-- tests/unit/40_core_2.bats | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/plugins/common/functions b/plugins/common/functions index 2781e0604..090c192ea 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -985,6 +985,7 @@ get_container_ports() { get_app_urls() { declare desc="print an app's available urls" + source "$PLUGIN_AVAILABLE_PATH/certs/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" @@ -1000,7 +1001,7 @@ get_app_urls() { local port_map app_vhost local app_vhosts=$(get_app_domains "$APP") for port_map in $DOKKU_PROXY_PORT_MAP; do - local scheme="$(awk -F ':' '{ print $1 }' <<< "$port_map")" + local scheme="$(awk -F ':' '{ print $1 }' <<< "$port_map")" local listen_port="$(awk -F ':' '{ print $2 }' <<< "$port_map")" for app_vhost in $app_vhosts; do if [[ "$listen_port" != "80" ]] && [[ "$listen_port" != "443" ]]; then @@ -1015,7 +1016,11 @@ get_app_urls() { local URLS="$(merge_dedupe_list "$port_urls $app_urls" " ")" case "$1" in url) - echo "$URLS" | tr ' ' '\n' | tail -1 + if is_ssl_enabled "$APP"; then + echo "$URLS" | tr ' ' '\n' | grep https | head -n1 + else + echo "$URLS" | tr ' ' '\n' | head -n1 + fi ;; urls) echo "$URLS" | tr ' ' '\n' | sort diff --git a/tests/unit/40_core_2.bats b/tests/unit/40_core_2.bats index 561901491..245a1999e 100644 --- a/tests/unit/40_core_2.bats +++ b/tests/unit/40_core_2.bats @@ -22,6 +22,15 @@ assert_urls() { assert_output < <(tr ' ' '\n' <<< "${urls}" | sort) } +assert_url() { + url=$1 + run dokku url $TEST_APP + echo "output: "$output + echo "status: "$status + echo "url: ${url}" + assert_output < <("${url}") +} + build_nginx_config() { # simulate nginx post-deploy dokku domains:setup $TEST_APP @@ -64,6 +73,15 @@ build_nginx_config() { assert_urls "http://test.dokku.me" "http://${TEST_APP}.dokku.me" "https://test.dokku.me" "https://${TEST_APP}.dokku.me" } +@test "(core) url (app ssl)" { + setup_test_tls + assert_url "https://dokku.me" + build_nginx_config + assert_url "https://${TEST_APP}.dokku.me" + add_domain "test.dokku.me" + assert_url "https://test.dokku.me" "https://${TEST_APP}.dokku.me" +} + @test "(core) urls (wildcard ssl)" { setup_test_tls wildcard assert_urls "https://dokku.me" From 7df06fb2f6fa28e557e51e4367baa35a2217af39 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 22 Jul 2017 15:17:40 -0600 Subject: [PATCH 4/4] fix: ensure tests pass --- plugins/common/functions | 2 +- tests/unit/40_core_2.bats | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/common/functions b/plugins/common/functions index 090c192ea..476422fe3 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -1001,7 +1001,7 @@ get_app_urls() { local port_map app_vhost local app_vhosts=$(get_app_domains "$APP") for port_map in $DOKKU_PROXY_PORT_MAP; do - local scheme="$(awk -F ':' '{ print $1 }' <<< "$port_map")" + local scheme="$(awk -F ':' '{ print $1 }' <<< "$port_map")" local listen_port="$(awk -F ':' '{ print $2 }' <<< "$port_map")" for app_vhost in $app_vhosts; do if [[ "$listen_port" != "80" ]] && [[ "$listen_port" != "443" ]]; then diff --git a/tests/unit/40_core_2.bats b/tests/unit/40_core_2.bats index 245a1999e..479b02213 100644 --- a/tests/unit/40_core_2.bats +++ b/tests/unit/40_core_2.bats @@ -28,7 +28,7 @@ assert_url() { echo "output: "$output echo "status: "$status echo "url: ${url}" - assert_output < <("${url}") + assert_output "${url}" } build_nginx_config() { @@ -78,8 +78,6 @@ build_nginx_config() { assert_url "https://dokku.me" build_nginx_config assert_url "https://${TEST_APP}.dokku.me" - add_domain "test.dokku.me" - assert_url "https://test.dokku.me" "https://${TEST_APP}.dokku.me" } @test "(core) urls (wildcard ssl)" {