Merge pull request #2260 from dokku/remove-port-mapping-tuple
Add ability to remove a specific port mapping tuple
This commit is contained in:
commit
3df37bcc99
4 files changed
+21
-5
No files matched your search
+1
-1
@@ -12,7 +12,7 @@ proxy:enable <app>
|
|||||||
proxy:ports <app> List proxy port mappings for app
|
proxy:ports <app> List proxy port mappings for app
|
||||||
proxy:ports-add <app> <scheme>:<host-port>:<container-port> [<scheme>:<host-port>:<container-port>...] Set proxy port mappings for app
|
proxy:ports-add <app> <scheme>:<host-port>:<container-port> [<scheme>:<host-port>:<container-port>...] Set proxy port mappings for app
|
||||||
proxy:ports-clear <app> Clear all proxy port mappings for app
|
proxy:ports-clear <app> Clear all proxy port mappings for app
|
||||||
proxy:ports-remove <app> <host-port> [<host-port>...] Unset proxy port mappings for app
|
proxy:ports-remove <app> <host-port> [<host-port>|<scheme>:<host-port>:<container-port>...] Unset proxy port mappings for app
|
||||||
proxy:set <app> <proxy-type> Set proxy type for app
|
proxy:set <app> <proxy-type> Set proxy type for app
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ case "$1" in
|
|||||||
proxy:ports <app>, List proxy port mappings for app
|
proxy:ports <app>, List proxy port mappings for app
|
||||||
proxy:ports-clear <app>, Clear all proxy port mappings for app
|
proxy:ports-clear <app>, Clear all proxy port mappings for app
|
||||||
proxy:ports-add <app> <scheme>:<host-port>:<container-port> [<scheme>:<host-port>:<container-port>...], Set proxy port mappings for app
|
proxy:ports-add <app> <scheme>:<host-port>:<container-port> [<scheme>:<host-port>:<container-port>...], Set proxy port mappings for app
|
||||||
proxy:ports-remove <app> <host-port> [<host-port>...], Unset proxy port mappings for app
|
proxy:ports-remove <app> <host-port> [<host-port>|<scheme>:<host-port>:<container-port>...], Unset proxy port mappings for app
|
||||||
proxy:set <app> <proxy-type>, Set proxy type for app
|
proxy:set <app> <proxy-type>, Set proxy type for app
|
||||||
help_content
|
help_content
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,19 @@ proxy_ports_remove_cmd() {
|
|||||||
local cmd="proxy:ports-remove"
|
local cmd="proxy:ports-remove"
|
||||||
local APP="$2"; verify_app_name "$APP"
|
local APP="$2"; verify_app_name "$APP"
|
||||||
local PROXY_PORT_MAP="$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)"
|
local PROXY_PORT_MAP="$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)"
|
||||||
|
local RE_PORT='^[0-9]+$'
|
||||||
shift 2
|
shift 2
|
||||||
|
|
||||||
local INPUT_PORTS="$*"
|
local INPUT_PORTS="$*"
|
||||||
if [[ -n "$INPUT_PORTS" ]]; then
|
if [[ -n "$INPUT_PORTS" ]]; then
|
||||||
local port
|
local port
|
||||||
|
PROXY_PORT_MAP=" $PROXY_PORT_MAP "
|
||||||
for port in $INPUT_PORTS; do
|
for port in $INPUT_PORTS; do
|
||||||
PROXY_PORT_MAP="$(sed -r "s/[[:alnum:]]+:$port:[[:alnum:]]+//g" <<< "$PROXY_PORT_MAP")"
|
if [[ "$port" =~ $RE_PORT ]]; then
|
||||||
|
PROXY_PORT_MAP="$(sed -r "s/[[:alnum:]]+:$port:[[:alnum:]]+//g" <<< "$PROXY_PORT_MAP")"
|
||||||
|
else
|
||||||
|
PROXY_PORT_MAP="$(sed -r "s/ $port / /g" <<< "$PROXY_PORT_MAP")"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
PROXY_PORT_MAP="$(echo "$PROXY_PORT_MAP" | xargs)"
|
PROXY_PORT_MAP="$(echo "$PROXY_PORT_MAP" | xargs)"
|
||||||
PROXY_PORT_MAP="$(merge_dedupe_list "$PROXY_PORT_MAP" " ")"
|
PROXY_PORT_MAP="$(merge_dedupe_list "$PROXY_PORT_MAP" " ")"
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ assert_external_port() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "(proxy) proxy:ports (list/add/remove/clear)" {
|
@test "(proxy) proxy:ports (list/add/remove/clear)" {
|
||||||
run dokku proxy:ports-add $TEST_APP http:8080:5000 https:8443:5000
|
run dokku proxy:ports-add $TEST_APP http:8080:5000 https:8443:5000 http:1234:5001
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_success
|
assert_success
|
||||||
@@ -72,13 +72,23 @@ assert_external_port() {
|
|||||||
run /bin/bash -c "dokku --quiet proxy:ports $TEST_APP | xargs"
|
run /bin/bash -c "dokku --quiet proxy:ports $TEST_APP | xargs"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_output "http 8080 5000 https 8443 5000"
|
assert_output "http 1234 5001 http 8080 5000 https 8443 5000"
|
||||||
|
|
||||||
run /bin/bash -c "dokku proxy:ports-remove $TEST_APP 8080"
|
run /bin/bash -c "dokku proxy:ports-remove $TEST_APP 8080"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku --quiet proxy:ports $TEST_APP | xargs"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_output "http 1234 5001 https 8443 5000"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku proxy:ports-remove $TEST_APP http:1234:5001"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
|
||||||
run /bin/bash -c "dokku --quiet proxy:ports $TEST_APP | xargs"
|
run /bin/bash -c "dokku --quiet proxy:ports $TEST_APP | xargs"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
|
|||||||
Reference in new issue
Block a user