Merge pull request #3147 from dokku/ports-set

Create proxy:ports-set call
This commit is contained in:
Jose Diaz-Gonzalez
2018-04-07 15:53:12 -04:00
committed by GitHub
6 changed files with 73 additions and 8 deletions

View File

@@ -66,7 +66,7 @@ filter_app_proxy_ports() {
}
add_proxy_ports() {
declare desc="add proxy port mappings from an app"
declare desc="add proxy port mappings for an app"
local APP="$1"
local PROXY_PORT_MAP="$(get_app_proxy_port_map "$APP")"
shift 1
@@ -82,7 +82,7 @@ add_proxy_ports() {
}
remove_proxy_ports() {
declare desc="remove specific proxy port mappings from an app"
declare desc="remove specific proxy port mappings for an app"
local APP="$1"
local PROXY_PORT_MAP="$(get_app_proxy_port_map "$APP")"
local RE_PORT='^[0-9]+$'
@@ -106,3 +106,18 @@ remove_proxy_ports() {
config_unset --no-restart "$APP" DOKKU_PROXY_PORT_MAP
fi
}
set_proxy_ports() {
declare desc="SET proxy port mappings for an app"
local APP="$1"
shift 1
local INPUT_PORTS="$*"
if [[ -n "$INPUT_PORTS" ]]; then
PROXY_PORT_MAP="$(merge_dedupe_list "$INPUT_PORTS" " ")"
config_set --no-restart "$APP" DOKKU_PROXY_PORT_MAP="$PROXY_PORT_MAP"
else
dokku proxy:help
dokku_log_fail "No port mapping specified. Exiting..."
fi
}

View File

@@ -1,7 +1,6 @@
#!/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"
proxy_ports_add_cmd() {

View File

@@ -2,7 +2,6 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
proxy_ports_remove_cmd() {
declare desc="remove specific proxy port mappings from an app"

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
proxy_ports_set_cmd() {
declare desc="add proxy port mappings from an app"
local cmd="proxy:add"
local APP="$2"; verify_app_name "$APP"
shift 2
set_proxy_ports "$APP" "$@"
plugn trigger post-proxy-ports-update "$APP" "add"
}
proxy_ports_set_cmd "$@"