Use dokku_log_fail in all cases where there is an exit 1

This commit is contained in:
Jose Diaz-Gonzalez
2015-09-04 00:17:45 -04:00
parent 76cf4d2969
commit 95161a2a9f
9 changed files with 37 additions and 42 deletions

View File

@@ -19,7 +19,7 @@ source "$PLUGIN_PATH/common/functions"
case "$1" in case "$1" in
hello) hello)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG) APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP" verify_app_name "$APP"
@@ -56,8 +56,7 @@ A few notes:
```shell ```shell
IMAGE=$(docker images | grep "user/repo" | awk '{print $3}') IMAGE=$(docker images | grep "user/repo" | awk '{print $3}')
if [[ -z $IMAGE ]]; then if [[ -z $IMAGE ]]; then
echo "user/repo image not found... Did you run 'dokku plugins-install'?" dokku_log_fail "user/repo image not found... Did you run 'dokku plugins-install'?"
exit 1
fi fi
``` ```

View File

@@ -101,8 +101,7 @@ case "$1" in
trace) trace)
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p $DOKKU_ROOT/.dokkurc [[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p $DOKKU_ROOT/.dokkurc
[[ "$2" == "on" ]] || [[ "$2" == "off" ]] || { [[ "$2" == "on" ]] || [[ "$2" == "off" ]] || {
echo "Valid trace options are [on/off]" dokku_log_fail "Valid trace options are [on/off]"
exit 1
} }
if [[ "$2" == "on" ]]; then if [[ "$2" == "on" ]]; then
@@ -121,7 +120,7 @@ case "$1" in
;; ;;
ls) ls)
dokku_apps=$(ls -d $DOKKU_ROOT/*/ 2>/dev/null) || (echo "You haven't deployed any applications yet" && exit 1) dokku_apps=$(ls -d $DOKKU_ROOT/*/ 2>/dev/null) || (dokku_log_fail "You haven't deployed any applications yet")
dokku_col_log_info1_quiet "App Name" "Container Type" "Container Id" "Status" dokku_col_log_info1_quiet "App Name" "Container Type" "Container Id" "Status"
@@ -143,7 +142,7 @@ case "$1" in
;; ;;
logs) logs)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; verify_app_name "$2" APP="$2"; verify_app_name "$2"
if (is_deployed $APP); then if (is_deployed $APP); then
@@ -169,7 +168,7 @@ case "$1" in
;; ;;
run) run)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG) APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
verify_app_name "$APP" verify_app_name "$APP"
@@ -185,7 +184,7 @@ case "$1" in
;; ;;
url | urls) url | urls)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; verify_app_name "$2" APP="$2"; verify_app_name "$2"
eval "$(config_export app $APP)" eval "$(config_export app $APP)"
@@ -217,10 +216,7 @@ case "$1" in
;; ;;
version) version)
cat "$DOKKU_ROOT/VERSION" || { cat "$DOKKU_ROOT/VERSION" || dokku_log_fail "Unable to determine dokku's version"
echo "Unable to determine dokku's version" 2>&1
exit 1
}
;; ;;
help) help)

View File

@@ -9,7 +9,7 @@ case "$1" in
;; ;;
apps:create) apps:create)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$2" ]] && dokku_log_warn "Name is already taken" && exit 1 [[ -d "$DOKKU_ROOT/$2" ]] && dokku_log_warn "Name is already taken" && exit 1
APP="$2" APP="$2"
@@ -18,8 +18,8 @@ case "$1" in
;; ;;
apps:destroy) apps:destroy)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ "$2" == "tls" ]] && echo "Unable to destroy tls directory" && exit 1 [[ "$2" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory"
[[ "$3" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1 [[ "$3" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP) APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
verify_app_name "$APP" verify_app_name "$APP"

View File

@@ -50,14 +50,12 @@ case "$1" in
tar xf $INPUT_FILE --directory=$BACKUP_TMP_DIR tar xf $INPUT_FILE --directory=$BACKUP_TMP_DIR
if [[ ! -f $BACKUP_TMP_DIR/.dokku_backup_version ]]; then if [[ ! -f $BACKUP_TMP_DIR/.dokku_backup_version ]]; then
echo "Unable to determine backup version" dokku_log_fail "Unable to determine backup version"
exit 1
fi fi
VERSION=$(< $BACKUP_TMP_DIR/.dokku_backup_version) VERSION=$(< $BACKUP_TMP_DIR/.dokku_backup_version)
if [[ $VERSION -ne 1 ]]; then if [[ $VERSION -ne 1 ]]; then
echo "Unknown format version $VERSION" dokku_log_fail "Unknown format version $VERSION"
exit 1
fi fi
echo "Importing a version $VERSION backup..." echo "Importing a version $VERSION backup..."
@@ -69,8 +67,7 @@ case "$1" in
if $force; then if $force; then
echo "-f used. Ignoring warnings." echo "-f used. Ignoring warnings."
else else
echo "Archive did not pass sanity checks. Use -f to import anyway" >&2 dokku_log_fail "Archive did not pass sanity checks. Use -f to import anyway"
exit 1
fi fi
fi fi

View File

@@ -66,7 +66,7 @@ case "$1" in
;; ;;
certs:generate) certs:generate)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" verify_app_name "$2"
APP="$2"; DOMAIN="$3"; SSL_PATH="$DOKKU_ROOT/$APP/tls" APP="$2"; DOMAIN="$3"; SSL_PATH="$DOKKU_ROOT/$APP/tls"
@@ -95,7 +95,7 @@ case "$1" in
;; ;;
certs:info) certs:info)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" verify_app_name "$2"
APP="$2"; SSL_TYPE=$(is_ssl_enabled $APP) APP="$2"; SSL_TYPE=$(is_ssl_enabled $APP)
case "$SSL_TYPE" in case "$SSL_TYPE" in
@@ -137,7 +137,7 @@ case "$1" in
;; ;;
certs:remove) certs:remove)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" verify_app_name "$2"
APP="$2"; APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" APP="$2"; APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
@@ -157,9 +157,12 @@ case "$1" in
help | certs:help) help | certs:help)
cat && cat<<EOF cat && cat<<EOF
certs:add <app> CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin certs:add <app> CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin
certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate.
certs:generate <app> DOMAIN, Generate a key and certificate signing request (and self-signed certificate) certs:generate <app> DOMAIN, Generate a key and certificate signing request (and self-signed certificate)
certs:info <app>, Show certificate information for an ssl endpoint. certs:info <app>, Show certificate information for an ssl endpoint.
certs:key <app> CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate.
certs:remove <app>, Remove an SSL Endpoint from an app. certs:remove <app>, Remove an SSL Endpoint from an app.
certs:rollback <app>, [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app.
certs:update <app> CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin certs:update <app> CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin
EOF EOF
;; ;;

View File

@@ -38,7 +38,7 @@ config_parse_args() {
if [[ "$DOKKU_CONFIG_TYPE" = "app" ]]; then if [[ "$DOKKU_CONFIG_TYPE" = "app" ]]; then
if [[ -z $APP ]]; then if [[ -z $APP ]]; then
echo "Please specify an app to run the command on" >&2 && exit 1 dokku_log_fail "Please specify an app to run the command on"
else else
verify_app_name "$2" verify_app_name "$2"
fi fi
@@ -105,7 +105,7 @@ config_all() {
is_config_export "$@" && config_export "$DOKKU_CONFIG_TYPE" "$APP" && exit 0 is_config_export "$@" && config_export "$DOKKU_CONFIG_TYPE" "$APP" && exit 0
[[ "$APP" ]] && DOKKU_CONFIG_TYPE=$APP [[ "$APP" ]] && DOKKU_CONFIG_TYPE=$APP
[[ ! -s $ENV_FILE ]] && echo "no config vars for $DOKKU_CONFIG_TYPE" && exit 1 [[ ! -s $ENV_FILE ]] && dokku_log_fail "no config vars for $DOKKU_CONFIG_TYPE"
VARS=$(grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | cut -d" " -f2-) VARS=$(grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" $ENV_FILE | cut -d" " -f2-)

View File

@@ -26,7 +26,7 @@ RE_IPV6="${RE_IPV6}\$"
case "$1" in case "$1" in
domains) domains)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" verify_app_name "$2"
APP="$2" APP="$2"
@@ -40,7 +40,7 @@ case "$1" in
;; ;;
domains:setup) domains:setup)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" verify_app_name "$2"
APP="$2"; VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" APP="$2"; VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
@@ -73,7 +73,7 @@ case "$1" in
;; ;;
domains:add) domains:add)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" verify_app_name "$2"
APP="$2" APP="$2"
@@ -103,7 +103,7 @@ case "$1" in
;; ;;
domains:clear) domains:clear)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" verify_app_name "$2"
APP="$2" APP="$2"
@@ -115,7 +115,7 @@ case "$1" in
;; ;;
domains:remove) domains:remove)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" verify_app_name "$2"
APP="$2" APP="$2"

View File

@@ -5,7 +5,7 @@ source "$(dirname $0)/functions"
case "$1" in case "$1" in
ps) ps)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; verify_app_name "$APP"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP) APP="$2"; verify_app_name "$APP"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP)
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0 ! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
@@ -17,7 +17,7 @@ case "$1" in
;; ;;
ps:start) ps:start)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP); APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP);
verify_app_name "$APP" verify_app_name "$APP"
@@ -31,7 +31,7 @@ case "$1" in
;; ;;
ps:stop) ps:stop)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP) APP="$2"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP)
verify_app_name "$APP" verify_app_name "$APP"
@@ -46,7 +46,7 @@ case "$1" in
;; ;;
ps:rebuild) ps:rebuild)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; verify_app_name "$APP" APP="$2"; verify_app_name "$APP"
pluginhook -p receive-app $APP pluginhook -p receive-app $APP
@@ -63,7 +63,7 @@ case "$1" in
;; ;;
ps:restart) ps:restart)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP) APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
verify_app_name "$APP" verify_app_name "$APP"
@@ -83,7 +83,7 @@ case "$1" in
;; ;;
ps:scale) ps:scale)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP) APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
verify_app_name "$APP" verify_app_name "$APP"

View File

@@ -5,7 +5,7 @@ source "$(dirname $0)/functions"
case "$1" in case "$1" in
tags) tags)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_REPO=$(get_app_image_repo $APP) APP="$2"; IMAGE_REPO=$(get_app_image_repo $APP)
verify_app_name "$APP" verify_app_name "$APP"
@@ -14,7 +14,7 @@ case "$1" in
;; ;;
tags:create) tags:create)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG="$3"; IMAGE_REPO=$(get_app_image_repo $APP) APP="$2"; IMAGE_TAG="$3"; IMAGE_REPO=$(get_app_image_repo $APP)
verify_app_name "$APP" verify_app_name "$APP"
@@ -24,7 +24,7 @@ case "$1" in
;; ;;
tags:deploy) tags:deploy)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG="$3" APP="$2"; IMAGE_TAG="$3"
verify_app_name "$APP" verify_app_name "$APP"
@@ -32,7 +32,7 @@ case "$1" in
;; ;;
tags:destroy) tags:destroy)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG="$3"; IMAGE_REPO=$(get_app_image_repo $APP) APP="$2"; IMAGE_TAG="$3"; IMAGE_REPO=$(get_app_image_repo $APP)
verify_app_name "$2" verify_app_name "$2"