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,12 +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/ps/functions"
ps_app_restart() {
declare desc="ps app-restart plugin trigger"
local trigger="ps_app_restart"
local APP="$1";
local APP="$1"
ps_restart "$APP"
}

View File

@@ -1,12 +1,13 @@
#!/usr/bin/env bash
[[ " help ps:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | ps:help)
help_content_func () {
help_content_func() {
declare desc="return ps plugin help content"
cat<<help_content
cat <<help_content
ps <app>, List processes running in app container(s)
ps:inspect <app>, Displays a sanitized version of docker inspect for an app
ps:scale <app> <proc>=<count> [<proc>=<count>...], Get/Set how many instances of a given process to run
@@ -25,15 +26,15 @@ case "$1" in
help_content
}
if [[ $1 = "ps:help" ]] ; then
echo -e 'Usage: dokku ps[:COMMAND]'
echo ''
echo 'List running processes in container, and restart app.'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
if [[ $1 == "ps:help" ]]; then
echo -e 'Usage: dokku ps[:COMMAND]'
echo ''
echo 'List running processes in container, and restart app.'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
else
help_content_func
help_content_func
fi
;;

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/ps/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"
@@ -16,10 +17,11 @@ get_cmd_from_procfile() {
print_dokku_scale_file() {
declare desc="prints contents of DOKKU_SCALE file"
local APP="$1"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
local APP="$1"
local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
while read -r line || [[ -n "$line" ]]; do
dokku_log_info2_quiet "$line"
done < "$DOKKU_SCALE_FILE"
done <"$DOKKU_SCALE_FILE"
}
extract_procfile() {
@@ -46,7 +48,8 @@ extract_procfile() {
remove_procfile() {
declare desc="removes DOKKU_PROCFILE"
local APP="$1"; local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
local APP="$1"
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
if [[ -f "$DOKKU_PROCFILE" ]]; then
rm -f "$DOKKU_PROCFILE"
fi
@@ -54,7 +57,10 @@ remove_procfile() {
generate_scale_file() {
declare desc="generates DOKKU_SCALE file"
local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG"); local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
local APP="$1"
local IMAGE_TAG="$2"
local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG")
local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
verify_app_name "$APP"
@@ -73,10 +79,10 @@ generate_scale_file() {
local NAME=${line%%:*}
local NUM_PROCS=0
[[ "$NAME" == "web" ]] && NUM_PROCS=1
[[ -n "$NAME" ]] && echo "$NAME=$NUM_PROCS" >> "$DOKKU_SCALE_FILE"
[[ -n "$NAME" ]] && echo "$NAME=$NUM_PROCS" >>"$DOKKU_SCALE_FILE"
done < <(egrep -v "^#" "$DOKKU_PROCFILE" | grep ':' | awk -F ':' '{ print $1 }' | sort | uniq)
else
echo "web=1" >> "$DOKKU_SCALE_FILE"
echo "web=1" >>"$DOKKU_SCALE_FILE"
fi
dokku_log_info1_quiet "New DOKKU_SCALE file generated"
else
@@ -92,30 +98,31 @@ set_scale() {
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
shift 1
extract_procfile "$APP" "$IMAGE_TAG" > /dev/null
extract_procfile "$APP" "$IMAGE_TAG" >/dev/null
trap 'remove_procfile $APP' RETURN INT TERM EXIT
local SCALE_SETTINGS=("$@")
for procscale in "${SCALE_SETTINGS[@]}"; do
local PROC_NAME=${procscale%%=*}
local PROC_COUNT=${procscale#*=}
if [[ -f "$DOKKU_PROCFILE" ]] && ! procfile-util exists --procfile "$DOKKU_PROCFILE" --process-type "$PROC_NAME" > /dev/null 2>&1; then
if [[ -f "$DOKKU_PROCFILE" ]] && ! procfile-util exists --procfile "$DOKKU_PROCFILE" --process-type "$PROC_NAME" >/dev/null 2>&1; then
dokku_log_fail "${PROC_NAME} is not a valid process name"
fi
is_number "$PROC_COUNT" || dokku_log_fail "ps:scale $PROC_COUNT is not a number"
dokku_log_info1_quiet "Scaling $APP:$PROC_NAME to $PROC_COUNT"
if (egrep -q "^${PROC_NAME}=" "$DOKKU_SCALE_FILE" > /dev/null 2>&1); then
if (egrep -q "^${PROC_NAME}=" "$DOKKU_SCALE_FILE" >/dev/null 2>&1); then
sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" "$DOKKU_SCALE_FILE"
else
echo "$PROC_NAME=$PROC_COUNT" >> "$DOKKU_SCALE_FILE"
echo "$PROC_NAME=$PROC_COUNT" >>"$DOKKU_SCALE_FILE"
fi
done
}
ps_start() {
declare desc="starts app"
local APP="$1"; verify_app_name "$APP"
local IMAGE_TAG=$(get_running_image_tag "$APP");
local APP="$1"
verify_app_name "$APP"
local IMAGE_TAG=$(get_running_image_tag "$APP")
local RUNNING
if (is_deployed "$APP"); then
@@ -139,7 +146,8 @@ ps_start() {
ps_stop() {
declare desc="stops app"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
! (is_deployed "$APP") && dokku_log_warn "App $APP has not been deployed" && exit 0
@@ -151,14 +159,16 @@ ps_stop() {
ps_rebuild() {
declare desc="rebuilds app from base image"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
plugn trigger receive-app "$APP"
}
ps_restart() {
declare desc="restarts app"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
local IMAGE_TAG=$(get_running_image_tag "$APP")
if (is_deployed "$APP"); then
@@ -170,14 +180,15 @@ ps_restart() {
ps_scale() {
declare desc="sets app scaling config according arguments; otherwise according to DOKKU_SCALE file"
local APP="$1"; verify_app_name "$APP"
local APP="$1"
verify_app_name "$APP"
local IMAGE_TAG=$(get_running_image_tag "$APP")
local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
shift 1
[[ ! -e $DOKKU_SCALE_FILE ]] && generate_scale_file "$APP" "$IMAGE_TAG"
if [[ -z "$@" ]];then
if [[ -z "$@" ]]; then
dokku_log_info1_quiet "Scaling for $APP"
dokku_col_log_info1_quiet "proctype" "qty"
dokku_col_log_info1_quiet "--------" "---"
@@ -186,7 +197,7 @@ ps_scale() {
local PROC_NAME=${line%%=*}
local PROC_COUNT=${line#*=}
dokku_col_log_info1 "$PROC_NAME" "$PROC_COUNT"
done < "$DOKKU_SCALE_FILE"
done <"$DOKKU_SCALE_FILE"
else
set_scale "$APP" "$@"
release_and_deploy "$APP" "$IMAGE_TAG"
@@ -196,7 +207,7 @@ ps_scale() {
get_raw_restart_policies() {
declare desc="strips docker options and prints raw restart policies"
local -r phase_file_path=$1
[[ -r "$phase_file_path" ]] && sed -e '/^--restart=/!d' < "$phase_file_path"
[[ -r "$phase_file_path" ]] && sed -e '/^--restart=/!d' <"$phase_file_path"
}
get_restart_policies() {
@@ -208,7 +219,7 @@ get_restart_policies() {
fn-ps-app-status() {
declare APP="$1"
local PROCS=0 RUNNING=""
local APP_CIDS=$(get_app_container_ids "$APP");
local APP_CIDS=$(get_app_container_ids "$APP")
for CID in $APP_CIDS; do
if (is_container_status "$CID" "Running"); then

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/docker-options/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"

View File

@@ -2,7 +2,8 @@
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-ps-inspect() {
declare desc="displays a sanitized version of docker inspect for an app"
@@ -58,8 +59,8 @@ cmd-ps-report-single() {
if [[ "$DOKKU_APP_RESTORE" != 0 ]]; then RESTORE="true"; else RESTORE="false"; fi
local APP_CONTAINER_STATUS
for CONTAINER_FILE in $CONTAINER_FILES; do
CID=$(< "$DOKKU_ROOT/$APP/$CONTAINER_FILE")
APP_CONTAINER_STATUS=$(docker inspect -f '{{.State.Status}}' "$CID" 2> /dev/null || true)
CID=$(<"$DOKKU_ROOT/$APP/$CONTAINER_FILE")
APP_CONTAINER_STATUS=$(docker inspect -f '{{.State.Status}}' "$CID" 2>/dev/null || true)
[[ -z "$APP_CONTAINER_STATUS" ]] && APP_CONTAINER_STATUS="missing"
STATUSES+=("${CONTAINER_FILE#*.}:$APP_CONTAINER_STATUS#${CID:0:12}")
done
@@ -85,7 +86,8 @@ cmd-ps-report-single() {
dokku_log_verbose "$(printf "%-30s %-10s (CID: %s)" "Status $name:" "$status" "$cid")"
done
else
local match=false; local value_exists=false
local match=false
local value_exists=false
for STATUS in "${STATUSES[@]}"; do
name=${STATUS%:*}
value=${STATUS#*:}

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/docker-options/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/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/ps/functions"
@@ -12,4 +13,4 @@ ps_post_stop() {
config_set --no-restart "$APP" DOKKU_APP_RESTORE=0
}
ps_post_stop "$@"
ps_post_stop "$@"

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/ps/functions"
ps_pre_deploy() {
declare desc="ps pre-deploy plugin trigger"
local trigger="ps_pre_deploy"
local APP="$1"; local IMAGE_TAG="$2"
local APP="$1"
local IMAGE_TAG="$2"
extract_procfile "$APP" "$IMAGE_TAG"
generate_scale_file "$APP" "$IMAGE_TAG"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-ps-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"
ps_main_cmd() {
@@ -9,7 +10,8 @@ ps_main_cmd() {
[[ -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"
! (is_deployed "$APP") && dokku_log_warn "App $APP has not been deployed" && exit 0
local DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids "$APP")

View File

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

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/ps/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/ps/functions"
@@ -9,7 +10,7 @@ ps_rebuildall_cmd() {
local cmd="ps:rebuildall"
local GNU_PARALLEL
if which parallel > /dev/null 2>&1; then
if which parallel >/dev/null 2>&1; then
dokku_log_info1 "Rebuilding in parallel"
GNU_PARALLEL=$(parallel -V 2>&1 | grep GNU || true)
if [[ -z "$GNU_PARALLEL" ]]; then

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
source "$PLUGIN_AVAILABLE_PATH/ps/internal-functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-ps-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/ps/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/docker-options/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/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/ps/functions"
@@ -9,7 +10,7 @@ ps_restartall_cmd() {
local cmd="ps:restartall"
local GNU_PARALLEL
if which parallel > /dev/null 2>&1; then
if which parallel >/dev/null 2>&1; then
dokku_log_info1 "Restarting in parallel"
GNU_PARALLEL=$(parallel -V 2>&1 | grep GNU || true)
if [[ -z "$GNU_PARALLEL" ]]; then

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/ps/functions"
@@ -27,11 +28,11 @@ ps_restore_cmd() {
ps_restore_all
fi
}
ps_restore_all() {
local GNU_PARALLEL
if which parallel > /dev/null 2>&1; then
if which parallel >/dev/null 2>&1; then
dokku_log_info1 "Restarting in parallel"
GNU_PARALLEL=$(parallel -V 2>&1 | grep GNU || true)
if [[ -z "$GNU_PARALLEL" ]]; then

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_AVAILABLE_PATH/config/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/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/ps/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/docker-options/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/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/ps/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/ps/functions"
@@ -9,7 +10,7 @@ ps_startall_cmd() {
local cmd="ps:startall"
local GNU_PARALLEL
if which parallel > /dev/null 2>&1; then
if which parallel >/dev/null 2>&1; then
dokku_log_info1 "Starting in parallel"
GNU_PARALLEL=$(parallel -V 2>&1 | grep GNU || true)
if [[ -z "$GNU_PARALLEL" ]]; then

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/ps/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/ps/functions"
@@ -9,7 +10,7 @@ ps_stopall_cmd() {
local cmd="ps:stopall"
local GNU_PARALLEL
if which parallel > /dev/null 2>&1; then
if which parallel >/dev/null 2>&1; then
dokku_log_info1 "Stopping in parallel"
GNU_PARALLEL=$(parallel -V 2>&1 | grep GNU || true)
if [[ -z "$GNU_PARALLEL" ]]; then