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 logs:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
source "$PLUGIN_AVAILABLE_PATH/logs/internal-functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
case "$1" in
|
||||
help | logs:help)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
fn-logs-usage() {
|
||||
declare desc="logs specific usage"
|
||||
@@ -14,14 +15,14 @@ fn-logs-usage() {
|
||||
|
||||
fn-logs-help-content() {
|
||||
declare desc="return logs plugin help content"
|
||||
cat<<help_content
|
||||
cat <<help_content
|
||||
logs <app> [-h] [-t] [-n num] [-q] [-p process], Display recent log output
|
||||
logs:failed <app>, Show the last logs for an application
|
||||
help_content
|
||||
}
|
||||
|
||||
cmd-logs-help() {
|
||||
if [[ $1 = "logs:help" ]] ; then
|
||||
if [[ $1 == "logs:help" ]]; then
|
||||
echo -e 'Usage: dokku logs[:COMMAND]'
|
||||
echo ''
|
||||
echo 'Output app logs'
|
||||
@@ -31,7 +32,7 @@ cmd-logs-help() {
|
||||
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
|
||||
fn-logs-help-content
|
||||
else
|
||||
cat<<help_desc
|
||||
cat <<help_desc
|
||||
logs, Output app logs
|
||||
help_desc
|
||||
fi
|
||||
|
||||
@@ -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/logs/internal-functions"
|
||||
|
||||
@@ -7,28 +8,47 @@ logs_default_cmd() {
|
||||
declare desc="display recent log output"
|
||||
local cmd="logs"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
local APP="$2"; verify_app_name "$2"
|
||||
local APP="$2"
|
||||
verify_app_name "$2"
|
||||
local APP_ROOT="$DOKKU_ROOT/$APP"
|
||||
local COLORS=(36 33 32 35 31)
|
||||
|
||||
! (is_deployed "$APP") && dokku_log_fail "App $APP has not been deployed"
|
||||
|
||||
shift 2;
|
||||
shift 2
|
||||
local TEMP=$(getopt -o htqn:p: --long help,tail,quiet,num:,ps: -n 'dokku logs' -- "$@")
|
||||
local EXIT_CODE="$?"
|
||||
if [[ "$EXIT_CODE" != 0 ]]; then fn-logs-usage >&2 ; exit 1 ; fi
|
||||
if [[ "$EXIT_CODE" != 0 ]]; then
|
||||
fn-logs-usage >&2
|
||||
exit 1
|
||||
fi
|
||||
eval set -- "$TEMP"
|
||||
|
||||
local DOKKU_LOGS_LINE_NUMBERS="100"
|
||||
while true; do
|
||||
case "$1" in
|
||||
-t|--tail) local DOKKU_LOGS_ARGS+="--follow "; shift ;;
|
||||
-n|--num) local DOKKU_LOGS_LINE_NUMBERS="$2"; shift 2 ;;
|
||||
-p|--ps) local DOKKU_LOGS_ONLY_PROCESS="$2"; shift 2 ;;
|
||||
-q|--quiet) local DOKKU_LOGS_NO_PRETTY_PRINT="true"; shift ;;
|
||||
--) shift; break ;;
|
||||
*) dokku_log_fail "Internal error";;
|
||||
esac
|
||||
case "$1" in
|
||||
-t | --tail)
|
||||
local DOKKU_LOGS_ARGS+="--follow "
|
||||
shift
|
||||
;;
|
||||
-n | --num)
|
||||
local DOKKU_LOGS_LINE_NUMBERS="$2"
|
||||
shift 2
|
||||
;;
|
||||
-p | --ps)
|
||||
local DOKKU_LOGS_ONLY_PROCESS="$2"
|
||||
shift 2
|
||||
;;
|
||||
-q | --quiet)
|
||||
local DOKKU_LOGS_NO_PRETTY_PRINT="true"
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*) dokku_log_fail "Internal error" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -n $DOKKU_LOGS_ONLY_PROCESS ]]; then
|
||||
@@ -39,10 +59,10 @@ logs_default_cmd() {
|
||||
[[ -z $(stat -t "${CONTAINERS[0]}" 2>/dev/null) ]] && exit 0
|
||||
|
||||
local DOKKU_LOGS_ARGS+="--tail $DOKKU_LOGS_LINE_NUMBERS"
|
||||
((MAX_INDEX=${#CONTAINERS[*]} - 1)) || true
|
||||
((MAX_INDEX = ${#CONTAINERS[*]} - 1)) || true
|
||||
for i in ${!CONTAINERS[*]}; do
|
||||
local DYNO=$(echo "${CONTAINERS[i]}" | sed -r 's/.*CONTAINER\.(.*)/\1/')
|
||||
local CID=$(< "${CONTAINERS[i]}")
|
||||
local CID=$(<"${CONTAINERS[i]}")
|
||||
local COLOR=${COLORS[i % ${#COLORS[*]}]}
|
||||
if [[ $DOKKU_LOGS_NO_PRETTY_PRINT == "true" ]]; then
|
||||
local DOKKU_LOGS_CMD+="(docker logs $DOKKU_LOGS_ARGS $CID 2>&1)"
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-logs-failed() {
|
||||
declare desc="shows the last failed deploy logs"
|
||||
declare cmd="logs:failed" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare cmd="logs:failed" argv=("$@")
|
||||
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare APP="$1"
|
||||
local DOKKU_SCHEDULER
|
||||
|
||||
|
||||
Reference in New Issue
Block a user