refactor: rewrite proxy plugin in golang

This commit is contained in:
Jose Diaz-Gonzalez committed 2020-02-22 06:40:24 -05:00
1 parent 26e8524ae5
commit 6fd4b5adb1
54 files changed
+1899 -514

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ trigger-nginx-vhosts-core-post-deploy() {
declare APP="$1"
local HAS_NETWORK_CONFIG
if [[ "$(get_app_proxy_type "$1")" != "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
return
fi
+1 -1
View File
@@ -295,7 +295,7 @@ nginx_build_config() {
local IS_APP_VHOST_ENABLED=$(is_app_vhost_enabled "$APP")
if [[ "$(is_app_proxy_enabled "$APP")" == "true" ]]; then
if [[ "$(plugn trigger proxy-is-enabled "$APP")" == "true" ]]; then
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -z "$DOKKU_APP_LISTEN_IP" ]]; then
DOKKU_APP_LISTENERS="$(plugn trigger network-get-listeners "$APP" | xargs)"
elif [[ -n "$DOKKU_APP_LISTEN_PORT" ]] && [[ -n "$DOKKU_APP_LISTEN_IP" ]]; then
-35
View File
@@ -1,35 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
trigger-nginx-vhosts-post-certs-update() {
declare desc="unset port config vars after SSL cert is added"
declare trigger="post-certs-update"
declare APP="$1"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
local DOKKU_PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
local DOKKU_PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
local DOKKU_PROXY_PORT_MAP=$(config_get "$APP" DOKKU_PROXY_PORT_MAP)
if [[ "$DOKKU_PROXY_PORT" == "80" ]]; then
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT
fi
if [[ "$DOKKU_PROXY_SSL_PORT" == "443" ]]; then
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_SSL_PORT
fi
if [[ "$DOKKU_PROXY_PORT_MAP" == *http:80:* ]]; then
# shellcheck disable=SC2046
remove_proxy_ports "$APP" $(filter_app_proxy_ports "$APP" "https" "443")
# shellcheck disable=SC2046
for port_map in $(filter_app_proxy_ports "$APP" "http" "80"); do
add_proxy_ports "$APP" "https:443:$(cut -d ':' -f3 <<<"$port_map")"
done
fi
fi
}
trigger-nginx-vhosts-post-certs-update "$@"
+1 -1
View File
@@ -12,7 +12,7 @@ trigger-nginx-vhosts-post-domains-update() {
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
nginx_build_config "$APP"
fi
}
+1 -1
View File
@@ -10,7 +10,7 @@ trigger-nginx-vhosts-post-proxy-ports-update() {
declare trigger="post-proxy-ports-update"
declare APP="$1" ACTION="$2"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
nginx_build_config "$APP"
fi
}
+1 -1
View File
@@ -10,7 +10,7 @@ trigger-nginx-vhosts-pre-disable-vhost() {
declare trigger="pre-disable-vhost"
declare APP="$1"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT DOKKU_PROXY_PORT_MAP
fi
}
+1 -1
View File
@@ -10,7 +10,7 @@ trigger-nginx-vhosts-pre-enable-vhost() {
declare trigger="pre-enable-vhost"
declare APP="$1"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT DOKKU_PROXY_PORT_MAP
fi
}
+1 -1
View File
@@ -11,7 +11,7 @@ trigger-nginx-vhosts-proxy-build-config() {
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
plugn trigger network-build-config "$APP"
nginx_build_config "$APP"
fi
+1 -1
View File
@@ -11,7 +11,7 @@ trigger-nginx-vhosts-proxy-clear-config() {
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
plugn trigger network-clear-config "$APP"
nginx_clear_config "$APP"
fi
+1 -1
View File
@@ -12,7 +12,7 @@ trigger-nginx-vhosts-proxy-disable() {
declare APP="$1"
verify_app_name "$APP"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
disable_app_vhost "$APP" --no-restart
ps_restart "$APP"
fi
+1 -1
View File
@@ -12,7 +12,7 @@ trigger-nginx-vhosts-proxy-enable() {
declare APP="$1"
verify_app_name "$APP"
if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
enable_app_vhost "$APP" --no-restart
ps_restart "$APP"
fi
@@ -12,7 +12,7 @@ cmd-nginx-build-config() {
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
local PROXY_APP_TYPE
PROXY_APP_TYPE="$(get_app_proxy_type "$APP")"
PROXY_APP_TYPE="$(plugn trigger proxy-type "$APP")"
if [[ "$PROXY_APP_TYPE" == "nginx" ]]; then
plugn trigger proxy-build-config "$APP"