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

@@ -101,8 +101,7 @@ case "$1" in
trace)
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p $DOKKU_ROOT/.dokkurc
[[ "$2" == "on" ]] || [[ "$2" == "off" ]] || {
echo "Valid trace options are [on/off]"
exit 1
dokku_log_fail "Valid trace options are [on/off]"
}
if [[ "$2" == "on" ]]; then
@@ -121,7 +120,7 @@ case "$1" in
;;
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"
@@ -143,7 +142,7 @@ case "$1" in
;;
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"
if (is_deployed $APP); then
@@ -169,7 +168,7 @@ case "$1" in
;;
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)
verify_app_name "$APP"
@@ -185,7 +184,7 @@ case "$1" in
;;
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"
eval "$(config_export app $APP)"
@@ -217,10 +216,7 @@ case "$1" in
;;
version)
cat "$DOKKU_ROOT/VERSION" || {
echo "Unable to determine dokku's version" 2>&1
exit 1
}
cat "$DOKKU_ROOT/VERSION" || dokku_log_fail "Unable to determine dokku's version"
;;
help)

View File

@@ -9,7 +9,7 @@ case "$1" in
;;
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
APP="$2"
@@ -18,8 +18,8 @@ case "$1" in
;;
apps:destroy)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ "$2" == "tls" ]] && echo "Unable to destroy tls directory" && exit 1
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ "$2" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory"
[[ "$3" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
verify_app_name "$APP"

View File

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

View File

@@ -66,7 +66,7 @@ case "$1" in
;;
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"
APP="$2"; DOMAIN="$3"; SSL_PATH="$DOKKU_ROOT/$APP/tls"
@@ -95,7 +95,7 @@ case "$1" in
;;
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"
APP="$2"; SSL_TYPE=$(is_ssl_enabled $APP)
case "$SSL_TYPE" in
@@ -137,7 +137,7 @@ case "$1" in
;;
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"
APP="$2"; APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
@@ -157,9 +157,12 @@ case "$1" in
help | certs:help)
cat && cat<<EOF
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: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: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
EOF
;;

View File

@@ -38,7 +38,7 @@ config_parse_args() {
if [[ "$DOKKU_CONFIG_TYPE" = "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
verify_app_name "$2"
fi
@@ -105,7 +105,7 @@ config_all() {
is_config_export "$@" && config_export "$DOKKU_CONFIG_TYPE" "$APP" && exit 0
[[ "$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-)

View File

@@ -26,7 +26,7 @@ RE_IPV6="${RE_IPV6}\$"
case "$1" in
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"
APP="$2"
@@ -40,7 +40,7 @@ case "$1" in
;;
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"
APP="$2"; VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
@@ -73,7 +73,7 @@ case "$1" in
;;
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"
APP="$2"
@@ -103,7 +103,7 @@ case "$1" in
;;
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"
APP="$2"
@@ -115,7 +115,7 @@ case "$1" in
;;
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"
APP="$2"

View File

@@ -5,7 +5,7 @@ source "$(dirname $0)/functions"
case "$1" in
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)
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
@@ -17,7 +17,7 @@ case "$1" in
;;
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);
verify_app_name "$APP"
@@ -31,7 +31,7 @@ case "$1" in
;;
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)
verify_app_name "$APP"
@@ -46,7 +46,7 @@ case "$1" in
;;
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"
pluginhook -p receive-app $APP
@@ -63,7 +63,7 @@ case "$1" in
;;
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)
verify_app_name "$APP"
@@ -83,7 +83,7 @@ case "$1" in
;;
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)
verify_app_name "$APP"

View File

@@ -5,7 +5,7 @@ source "$(dirname $0)/functions"
case "$1" in
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)
verify_app_name "$APP"
@@ -14,7 +14,7 @@ case "$1" in
;;
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)
verify_app_name "$APP"
@@ -24,7 +24,7 @@ case "$1" in
;;
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"
verify_app_name "$APP"
@@ -32,7 +32,7 @@ case "$1" in
;;
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)
verify_app_name "$2"