tests: run mvdan/shfmt on test runs

While I do not agree with _every_ style change, this will force Dokku to have consistent formatting across all shell scripts, which is arguably a Good Thing™.

The command used to reprocess everything is:

```shell
shfmt -l -bn -ci -i 2 -w .
```
This commit is contained in:
Jose Diaz-Gonzalez
2019-01-07 01:04:17 -05:00
parent fb7c73a7e3
commit 86795ddacc
283 changed files with 1536 additions and 1018 deletions

View File

@@ -1,7 +1,8 @@
#!/usr/bin/env bash
[[ " help proxy:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/proxy/internal-functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | proxy:help)

View File

@@ -1,11 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
is_app_proxy_enabled() {
declare desc="return true if proxy is enabled; otherwise return false"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
local APP_PROXY_ENABLED=true
local DOKKU_DISABLE_PROXY=$(config_get "$APP" DOKKU_DISABLE_PROXY)
@@ -17,7 +19,8 @@ is_app_proxy_enabled() {
get_app_proxy_type() {
declare desc="return app proxy type"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
local DOKKU_APP_PROXY_TYPE="$(config_get "$APP" DOKKU_APP_PROXY_TYPE || true)"
local APP_PROXY_TYPE="${DOKKU_APP_PROXY_TYPE:-nginx}"
@@ -26,13 +29,15 @@ get_app_proxy_type() {
get_app_proxy_port_map() {
declare desc="return a list of configured port mappings"
local APP="$1"; local PROXY_PORT_MAP="$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)"
local APP="$1"
local PROXY_PORT_MAP="$(config_get "$APP" DOKKU_PROXY_PORT_MAP || true)"
echo "$PROXY_PORT_MAP"
}
list_app_proxy_ports() {
declare desc="list proxy port mappings for an app"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
local PROXY_PORT_MAP="$(get_app_proxy_port_map "$APP")"
if [[ -n "$PROXY_PORT_MAP" ]]; then
@@ -40,7 +45,7 @@ list_app_proxy_ports() {
dokku_col_log_info1_quiet "scheme" "host port" "container port"
local port_map
for port_map in $PROXY_PORT_MAP; do
dokku_col_log_msg "$(cut -d ':' -f1 <<< "$port_map")" "$(cut -d ':' -f2 <<< "$port_map")" "$(cut -d ':' -f3 <<< "$port_map")"
dokku_col_log_msg "$(cut -d ':' -f1 <<<"$port_map")" "$(cut -d ':' -f2 <<<"$port_map")" "$(cut -d ':' -f3 <<<"$port_map")"
done
else
dokku_log_fail "No port mappings configured for app ($APP)"
@@ -49,15 +54,16 @@ list_app_proxy_ports() {
filter_app_proxy_ports() {
declare desc="list proxy port mappings for an app that start with a particular scheme and a host port"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
local SCHEME="$2" HOST_PORT="$3"
local PROXY_PORT_MAP="$(get_app_proxy_port_map "$APP")"
if [[ -n "$PROXY_PORT_MAP" ]]; then
local port_map
for port_map in $PROXY_PORT_MAP; do
local scheme="$(cut -d ':' -f1 <<< "$port_map")"
local host_port="$(cut -d ':' -f2 <<< "$port_map")"
local scheme="$(cut -d ':' -f1 <<<"$port_map")"
local host_port="$(cut -d ':' -f2 <<<"$port_map")"
if [[ "$scheme" == "$SCHEME" ]] && [[ "$host_port" == "$HOST_PORT" ]]; then
echo "$port_map"
fi
@@ -93,9 +99,9 @@ remove_proxy_ports() {
PROXY_PORT_MAP=" $PROXY_PORT_MAP "
for port in $INPUT_PORTS; do
if [[ "$port" =~ $RE_PORT ]]; then
PROXY_PORT_MAP="$(sed -r "s/[[:alnum:]]+:$port:[[:alnum:]]+//g" <<< "$PROXY_PORT_MAP")"
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")"
PROXY_PORT_MAP="$(sed -r "s/ $port / /g" <<<"$PROXY_PORT_MAP")"
fi
done
PROXY_PORT_MAP="$(echo "$PROXY_PORT_MAP" | xargs)"

View File

@@ -1,7 +1,8 @@
#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-proxy-report() {
declare desc="displays a proxy report for one or more apps"
@@ -46,7 +47,8 @@ cmd-proxy-report-single() {
dokku_log_verbose "$(printf "%-30s %-25s" "${key^}" "${flag#*: }")"
done
else
local match=false; local value_exists=false
local match=false
local value_exists=false
for flag in "${flag_map[@]}"; do
valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)"
if [[ "$flag" == "${INFO_FLAG}:"* ]]; then
@@ -75,8 +77,8 @@ fn-proxy-enabled() {
}
proxy_help_content_func() {
declare desc="return proxy plugin help content"
cat<<help_content
declare desc="return proxy plugin help content"
cat <<help_content
proxy <app>, [DEPRECATED] Show proxy settings for app
proxy:enable <app>, Enable proxy for app
proxy:disable <app>, Disable proxy for app
@@ -90,7 +92,7 @@ help_content
}
proxy_help_cmd() {
if [[ $1 = "proxy:help" ]] ; then
if [[ $1 == "proxy:help" ]]; then
echo -e 'Usage: dokku proxy[:COMMAND]'
echo ''
echo 'Manage the proxy used by dokku on a per app.'
@@ -100,7 +102,7 @@ proxy_help_cmd() {
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
proxy_help_content_func
else
cat<<help_desc
cat <<help_desc
proxy, Manage the proxy used by dokku on a per app
help_desc
fi

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
source "$PLUGIN_AVAILABLE_PATH/proxy/internal-functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-proxy-report-single "$@"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
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"
@@ -8,7 +9,8 @@ proxy_disable_cmd() {
declare desc="disable proxy for app via command line"
local cmd="proxy:disable"
[[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
if [[ "$(is_app_proxy_enabled "$APP")" == "true" ]]; then
dokku_log_info1 "Disabling proxy for app ($APP)"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
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"
@@ -8,7 +9,8 @@ proxy_enable_cmd() {
declare desc="enable proxy for app via command line"
local cmd="proxy:enable"
[[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
if [[ "$(is_app_proxy_enabled "$APP")" == "false" ]]; then
dokku_log_info1 "Enabling proxy for app ($APP)"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
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"
@@ -7,7 +8,8 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions"
proxy_ports_cmd() {
declare desc="cmd wrapper to list proxy port mappings for an app"
local cmd="proxy:ports"
local APP="$2"; verify_app_name "$APP"
local APP="$2"
verify_app_name "$APP"
list_app_proxy_ports "$APP"
}

View File

@@ -1,12 +1,14 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
proxy_ports_add_cmd() {
declare desc="add proxy port mappings from an app"
local cmd="proxy:add"
local APP="$2"; verify_app_name "$APP"
local APP="$2"
verify_app_name "$APP"
shift 2
add_proxy_ports "$APP" "$@"

View File

@@ -1,12 +1,14 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
proxy_ports_clear_cmd() {
declare desc="clear all proxy port mappings for an app"
local cmd="proxy:clear"
local APP="$2"; verify_app_name "$APP"
local APP="$2"
verify_app_name "$APP"
config_unset --no-restart "$APP" DOKKU_PROXY_PORT_MAP
plugn trigger post-proxy-ports-update "$APP" "clear"

View File

@@ -1,12 +1,14 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
proxy_ports_remove_cmd() {
declare desc="remove specific proxy port mappings from an app"
local cmd="proxy:ports-remove"
local APP="$2"; verify_app_name "$APP"
local APP="$2"
verify_app_name "$APP"
shift 2
local INPUT_PORTS="$*"

View File

@@ -1,12 +1,14 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
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"
local APP="$2"
verify_app_name "$APP"
shift 2
set_proxy_ports "$APP" "$@"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
source "$PLUGIN_AVAILABLE_PATH/proxy/internal-functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-proxy-report "$@"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
@@ -8,7 +9,8 @@ proxy_set_cmd() {
local cmd="proxy:set"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
local APP="$2"; verify_app_name "$APP"
local APP="$2"
verify_app_name "$APP"
local PROXY_TYPE="$3"
if [[ -n "$PROXY_TYPE" ]]; then