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:
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " help domains:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/internal-functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
case "$1" in
|
||||
help | domains:help)
|
||||
|
||||
@@ -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"
|
||||
|
||||
disable_app_vhost() {
|
||||
declare desc="disable vhost support for given application"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
local APP=$1; verify_app_name "$APP"
|
||||
local APP=$1
|
||||
verify_app_name "$APP"
|
||||
local APP_VHOST_FILE="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP_URLS_FILE="$DOKKU_ROOT/$APP/URLS"
|
||||
|
||||
@@ -28,14 +30,17 @@ disable_app_vhost() {
|
||||
domains_setup() {
|
||||
declare desc="setup domains to default state"
|
||||
verify_app_name "$1"
|
||||
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"; local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
||||
local RE_IPV4="$(get_ipv4_regex)"; local RE_IPV6="$(get_ipv6_regex)"
|
||||
local APP="$1"
|
||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
||||
local RE_IPV4="$(get_ipv4_regex)"
|
||||
local RE_IPV6="$(get_ipv6_regex)"
|
||||
local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")"
|
||||
|
||||
if [[ ! -f $APP_VHOST_PATH ]]; then
|
||||
if [[ -n "$DEFAULT_VHOSTS" ]]; then
|
||||
dokku_log_info1 "Creating new $APP_VHOST_PATH..."
|
||||
echo "$DEFAULT_VHOSTS" > "$APP_VHOST_PATH"
|
||||
echo "$DEFAULT_VHOSTS" >"$APP_VHOST_PATH"
|
||||
else
|
||||
dokku_log_info2 "no global VHOST set. disabling vhost support"
|
||||
disable_app_vhost "$APP" --no-restart
|
||||
@@ -46,7 +51,8 @@ domains_setup() {
|
||||
domains_add() {
|
||||
declare desc="add list of domains to app"
|
||||
verify_app_name "$1"
|
||||
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP="$1"
|
||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
|
||||
shift 1
|
||||
for DOMAIN in "$@"; do
|
||||
@@ -56,10 +62,13 @@ domains_add() {
|
||||
done
|
||||
|
||||
for DOMAIN in "$@"; do
|
||||
if [[ $(egrep -w "^$DOMAIN$" "$APP_VHOST_PATH" > /dev/null 2>&1; echo $?) -eq 0 ]]; then
|
||||
if [[ $(
|
||||
egrep -w "^$DOMAIN$" "$APP_VHOST_PATH" >/dev/null 2>&1
|
||||
echo $?
|
||||
) -eq 0 ]]; then
|
||||
dokku_log_info1 "Skipping: $DOMAIN already added to $APP"
|
||||
else
|
||||
echo "$DOMAIN" >> "$APP_VHOST_PATH"
|
||||
echo "$DOMAIN" >>"$APP_VHOST_PATH"
|
||||
dokku_log_info1 "Added $DOMAIN to $APP"
|
||||
fi
|
||||
done
|
||||
@@ -74,7 +83,8 @@ domains_add() {
|
||||
domains_remove() {
|
||||
declare desc="remove list of app domains"
|
||||
verify_app_name "$1"
|
||||
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP="$1"
|
||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
shift 1
|
||||
|
||||
touch "$APP_VHOST_PATH"
|
||||
@@ -88,7 +98,8 @@ domains_remove() {
|
||||
domains_set() {
|
||||
declare desc="set list of domains for app"
|
||||
verify_app_name "$1"
|
||||
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP="$1"
|
||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
|
||||
shift 1
|
||||
touch "$APP_VHOST_PATH"
|
||||
@@ -98,7 +109,7 @@ domains_set() {
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$*" | tr " " "\n" > "$APP_VHOST_PATH"
|
||||
echo "$*" | tr " " "\n" >"$APP_VHOST_PATH"
|
||||
dokku_log_info1 "Set $* for $APP"
|
||||
|
||||
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
|
||||
@@ -111,7 +122,8 @@ domains_set() {
|
||||
domains_disable() {
|
||||
declare desc="disable domains/VHOST support"
|
||||
verify_app_name "$1"
|
||||
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP="$1"
|
||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
|
||||
touch "$APP_VHOST_PATH"
|
||||
if [[ "$(is_app_vhost_enabled "$APP")" == "true" ]]; then
|
||||
@@ -124,13 +136,14 @@ domains_disable() {
|
||||
domains_enable() {
|
||||
declare desc="enable domains/VHOST support"
|
||||
verify_app_name "$1"
|
||||
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP="$1"
|
||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")"
|
||||
|
||||
touch "$APP_VHOST_PATH"
|
||||
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
|
||||
if [[ -n "$DEFAULT_VHOSTS" ]]; then
|
||||
echo "$DEFAULT_VHOSTS" > "$APP_VHOST_PATH"
|
||||
echo "$DEFAULT_VHOSTS" >"$APP_VHOST_PATH"
|
||||
fi
|
||||
[[ "$2" == "--no-restart" ]] && local ENABLE_APP_VHOST_ARGS=$2
|
||||
enable_app_vhost "$APP" "$ENABLE_APP_VHOST_ARGS"
|
||||
@@ -151,7 +164,10 @@ domains_add_global() {
|
||||
done
|
||||
|
||||
for DOMAIN in "$@"; do
|
||||
if [[ $(egrep -w "^$DOMAIN$" "$GLOBAL_VHOST_PATH" > /dev/null 2>&1; echo $?) -eq 0 ]]; then
|
||||
if [[ $(
|
||||
egrep -w "^$DOMAIN$" "$GLOBAL_VHOST_PATH" >/dev/null 2>&1
|
||||
echo $?
|
||||
) -eq 0 ]]; then
|
||||
dokku_log_info1 "Skipping: $DOMAIN already added"
|
||||
else
|
||||
sed -i -e "\$a\\$DOMAIN" "$GLOBAL_VHOST_PATH"
|
||||
@@ -182,7 +198,7 @@ domains_set_global() {
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$*" | tr " " "\n" > "$GLOBAL_VHOST_PATH"
|
||||
echo "$*" | tr " " "\n" >"$GLOBAL_VHOST_PATH"
|
||||
dokku_log_info1 "Set $*"
|
||||
}
|
||||
|
||||
@@ -190,7 +206,8 @@ enable_app_vhost() {
|
||||
declare desc="enable vhost support for given application"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
local APP=$1; verify_app_name "$APP"
|
||||
local APP=$1
|
||||
verify_app_name "$APP"
|
||||
|
||||
plugn trigger pre-enable-vhost "$APP"
|
||||
[[ "$2" == "--no-restart" ]] && local CONFIG_SET_ARGS=$2
|
||||
@@ -201,7 +218,8 @@ enable_app_vhost() {
|
||||
get_app_domains() {
|
||||
declare desc="return app domains"
|
||||
verify_app_name "$1"
|
||||
local APP=$1; local APP_VHOST_FILE="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP=$1
|
||||
local APP_VHOST_FILE="$DOKKU_ROOT/$APP/VHOST"
|
||||
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
||||
local GLOBAL_HOSTNAME_PATH="$DOKKU_ROOT/HOSTNAME"
|
||||
|
||||
@@ -219,8 +237,9 @@ get_app_domains() {
|
||||
get_default_vhosts() {
|
||||
declare desc="return default vhosts"
|
||||
verify_app_name "$1"
|
||||
local APP="$1"; local RE_IPV4="$(get_ipv4_regex)"; local RE_IPV6="$(get_ipv6_regex)"
|
||||
|
||||
local APP="$1"
|
||||
local RE_IPV4="$(get_ipv4_regex)"
|
||||
local RE_IPV6="$(get_ipv6_regex)"
|
||||
|
||||
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then
|
||||
local VHOSTS=$(get_global_vhosts)
|
||||
@@ -238,14 +257,14 @@ get_default_vhosts() {
|
||||
fi
|
||||
echo "$hostname"
|
||||
fi
|
||||
done <<< "$VHOSTS"
|
||||
done <<<"$VHOSTS"
|
||||
fi
|
||||
}
|
||||
|
||||
get_global_vhosts() {
|
||||
declare desc="return global vhosts"
|
||||
local GLOBAL_VHOST_FILE="$DOKKU_ROOT/VHOST"
|
||||
[[ -f "$GLOBAL_VHOST_FILE" ]] && local GLOBAL_VHOSTS=$(< "$GLOBAL_VHOST_FILE")
|
||||
[[ -f "$GLOBAL_VHOST_FILE" ]] && local GLOBAL_VHOSTS=$(<"$GLOBAL_VHOST_FILE")
|
||||
echo "$GLOBAL_VHOSTS"
|
||||
}
|
||||
|
||||
@@ -253,7 +272,8 @@ is_app_vhost_enabled() {
|
||||
declare desc="returns true or false if vhost support is enabled for a given application"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
local APP=$1; verify_app_name "$APP"
|
||||
local APP=$1
|
||||
verify_app_name "$APP"
|
||||
local NO_VHOST=$(config_get "$APP" NO_VHOST)
|
||||
local APP_VHOST_ENABLED=true
|
||||
|
||||
@@ -276,14 +296,15 @@ is_global_vhost_enabled() {
|
||||
local GLOBAL_VHOSTS_ENABLED=true
|
||||
break
|
||||
fi
|
||||
done <<< "$GLOBAL_VHOSTS"
|
||||
done <<<"$GLOBAL_VHOSTS"
|
||||
|
||||
echo $GLOBAL_VHOSTS_ENABLED
|
||||
}
|
||||
|
||||
is_valid_hostname() {
|
||||
declare desc="return 0 if argument is a valid hostname; else return 1"
|
||||
local hostname_string="${1,,}"; local hostname_regex='^([a-z0-9\*-]+\.)*[a-z0-9\*-]+$'
|
||||
local hostname_string="${1,,}"
|
||||
local hostname_regex='^([a-z0-9\*-]+\.)*[a-z0-9\*-]+$'
|
||||
if [[ $hostname_string =~ $hostname_regex ]]; then
|
||||
return 0
|
||||
else
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||
shopt -s nullglob
|
||||
|
||||
for app in $DOKKU_ROOT/*/CONTAINER; do
|
||||
APP=$(basename "$(dirname "$app")");
|
||||
APP=$(basename "$(dirname "$app")")
|
||||
domains_setup "$APP"
|
||||
done
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-domains-report() {
|
||||
declare desc="displays a domains report for one or more apps"
|
||||
@@ -47,7 +48,8 @@ cmd-domains-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
|
||||
@@ -65,9 +67,9 @@ cmd-domains-report-single() {
|
||||
fi
|
||||
}
|
||||
|
||||
domains_help_content_func () {
|
||||
declare desc="return domains plugin help content"
|
||||
cat<<help_content
|
||||
domains_help_content_func() {
|
||||
declare desc="return domains plugin help content"
|
||||
cat <<help_content
|
||||
domains [<app>], [DEPRECATED] Alternative for domains:report
|
||||
domains:add <app> <domain> [<domain> ...], Add domains to app
|
||||
domains:add-global <domain> [<domain> ...], Add global domain names
|
||||
@@ -83,7 +85,7 @@ help_content
|
||||
}
|
||||
|
||||
domains_help_cmd() {
|
||||
if [[ $1 = "domains:help" ]] ; then
|
||||
if [[ $1 == "domains:help" ]]; then
|
||||
echo -e 'Usage: dokku domains[:COMMAND]'
|
||||
echo ''
|
||||
echo 'Manage vhost domains used by the Dokku proxy.'
|
||||
@@ -93,7 +95,7 @@ domains_help_cmd() {
|
||||
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
|
||||
domains_help_content_func
|
||||
else
|
||||
cat<<help_desc
|
||||
cat <<help_desc
|
||||
domains, Manage vhost domains used by the Dokku proxy
|
||||
help_desc
|
||||
fi
|
||||
@@ -112,7 +114,7 @@ fn-domains-app-vhosts() {
|
||||
declare APP="$1"
|
||||
local APP_VHOST_FILE="$DOKKU_ROOT/$APP/VHOST"
|
||||
if [[ -f "$APP_VHOST_FILE" ]]; then
|
||||
tr '\n' ' ' < "$APP_VHOST_FILE"
|
||||
tr '\n' ' ' <"$APP_VHOST_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
domains_post_app_clone_setup() {
|
||||
declare desc="removes domain files when setting up a clone"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/internal-functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-domains-report-single "$@"
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
@@ -8,7 +9,8 @@ domains_clear_cmd() {
|
||||
local cmd="domains:clear"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
verify_app_name "$2"
|
||||
local APP="$2"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
local APP="$2"
|
||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
|
||||
rm -f "$APP_VHOST_PATH"
|
||||
domains_setup "$APP"
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/domains/internal-functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-domains-report "$@"
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
@@ -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/domains/functions"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user