From 8eccd50ecb7b085c7a9b5c007c5a7473b8b071ef Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 4 Jan 2021 22:38:28 -0500 Subject: [PATCH 1/3] chore: standardize logging output - send errors to stderr - use proper prefixes on errors - use correct prefixes on stdout --- contrib/dokku_client.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/dokku_client.sh b/contrib/dokku_client.sh index a377ae38f..1cce46749 100755 --- a/contrib/dokku_client.sh +++ b/contrib/dokku_client.sh @@ -32,8 +32,8 @@ fn-random-name() { } fn-client-help-msg() { - echo "==> Configure the DOKKU_HOST environment variable or run $0 from a repository with a git remote named dokku" 1>&2 - echo "--> i.e. git remote add dokku dokku@:" 1>&2 + echo "=====> Configure the DOKKU_HOST environment variable or run $0 from a repository with a git remote named dokku" + echo " i.e. git remote add dokku dokku@:" exit 20 # exit with specific status. only used in units tests for now } @@ -107,7 +107,7 @@ main() { APP=$(git remote -v 2>/dev/null | grep -Ei "dokku@$DOKKU_REMOTE_HOST" | head -n 1 | cut -f2 -d'@' | cut -f1 -d' ' | cut -f2 -d':' 2>/dev/null) set -e else - echo "This is not a git repository" + echo " ! This is not a git repository" 1>&2 fi fi @@ -118,7 +118,7 @@ main() { counter=0 while ssh -p "$DOKKU_PORT" "dokku@$DOKKU_REMOTE_HOST" apps 2>/dev/null | grep -q "$APP"; do if [[ $counter -ge 100 ]]; then - echo "Error: could not reasonably generate a new app name. try cleaning up some apps..." + echo " ! Could not reasonably generate a new app name. Try cleaning up some apps..." 1>&2 ssh -p "$DOKKU_PORT" "dokku@$DOKKU_REMOTE_HOST" apps exit 1 else @@ -133,7 +133,7 @@ main() { echo "-----> Dokku remote added at ${DOKKU_REMOTE_HOST} called ${DOKKU_GIT_REMOTE}" echo "-----> Application name is ${APP}" else - echo "! Dokku remote not added! Do you already have a dokku remote?" + echo " ! Dokku remote not added! Do you already have a dokku remote?" 1>&2 return fi ;; From 83d8c8448b2b38ef7dbe774d2066f9899ad5a1b5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 4 Jan 2021 22:41:04 -0500 Subject: [PATCH 2/3] feat: remind users to check their ssh config in cases of ssh error Closes #4278 --- contrib/dokku_client.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/dokku_client.sh b/contrib/dokku_client.sh index 1cce46749..96a949665 100755 --- a/contrib/dokku_client.sh +++ b/contrib/dokku_client.sh @@ -149,7 +149,12 @@ main() { [[ -n "$@" ]] && [[ -n "$APP" ]] && app_arg="--app $APP" # echo "ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_REMOTE_HOST -- $app_arg $@" # shellcheck disable=SC2068,SC2086 - ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_REMOTE_HOST -- $app_arg $@ + ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_REMOTE_HOST -- $app_arg $@ || { + ssh_exit_code="$?" + echo " ! Failed to execute dokku command over ssh: exit code $?" 1>&2 + echo " ! If there was no output from Dokku, ensure your configured SSH Key can connect to the remote server" 1>&2 + echo $ssh_exit_code + } } if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]] || [[ "$0" == $(which dokku) ]]; then From 540e066acf2d081be02efad0f91ae6d86b1a46a8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 5 Jan 2021 00:10:54 -0500 Subject: [PATCH 3/3] fix: return the failed exit code --- contrib/dokku_client.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/dokku_client.sh b/contrib/dokku_client.sh index 96a949665..bd7fdd583 100755 --- a/contrib/dokku_client.sh +++ b/contrib/dokku_client.sh @@ -153,7 +153,7 @@ main() { ssh_exit_code="$?" echo " ! Failed to execute dokku command over ssh: exit code $?" 1>&2 echo " ! If there was no output from Dokku, ensure your configured SSH Key can connect to the remote server" 1>&2 - echo $ssh_exit_code + return $ssh_exit_code } }