mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Because of how plugin commands are implemented, their output can be incredibly verbose. Rather than executing even the `set -eo pipefail` parts of a plugin, we immediately check if the command is implemented by a plugin. If it is not, then we continue on as normal. One side-effect of this change is that plugin commands need to be duplicated again: - once in the command array - once for the actual body of the command - once in the help output This is also quite hackish, and probably not the best way to decrease trace output. Note that we drop approximately 2k lines worth of logs with this change.
67 lines
2.0 KiB
Bash
Executable File
67 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
[[ " apps apps:create apps:destroy help apps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT
|
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
|
|
case "$1" in
|
|
apps)
|
|
dokku_log_info2_quiet "My Apps"
|
|
find $DOKKU_ROOT -follow -maxdepth 1 -type d \( ! -iname ".*" \) -not -path $DOKKU_ROOT/tls | sed 's|^\./||g' | sed 's|'$DOKKU_ROOT'\/||' | tail -n +2 | sort
|
|
;;
|
|
|
|
apps:create)
|
|
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
[[ -d "$DOKKU_ROOT/$2" ]] && dokku_log_fail "Name is already taken"
|
|
APP="$2"
|
|
|
|
mkdir -p "$DOKKU_ROOT/$APP"
|
|
echo "Creating $APP... done"
|
|
;;
|
|
|
|
apps:destroy)
|
|
[[ -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"
|
|
|
|
if [[ -z "$DOKKU_APPS_FORCE_DELETE" ]]; then
|
|
dokku_log_warn "WARNING: Potentially Destructive Action"
|
|
dokku_log_warn "This command will destroy $APP (including all add-ons)."
|
|
dokku_log_warn "To proceed, type \"$APP\""
|
|
echo ""
|
|
|
|
read -p "> " app_name
|
|
if [[ "$app_name" != "$APP" ]]; then
|
|
dokku_log_fail "Confirmation did not match $APP. Aborted."
|
|
fi
|
|
fi
|
|
|
|
echo "Destroying $APP (including all add-ons)"
|
|
|
|
plugn trigger pre-delete $APP $IMAGE_TAG
|
|
DOKKU_APP_CIDS=$(get_app_container_ids $APP)
|
|
if [[ -n $DOKKU_APP_CIDS ]]; then
|
|
for ID in $DOKKU_APP_CIDS; do
|
|
docker stop $ID > /dev/null || true
|
|
docker rm $ID > /dev/null || true
|
|
done
|
|
fi
|
|
|
|
plugn trigger post-delete $APP $IMAGE_TAG
|
|
;;
|
|
|
|
help | apps:help)
|
|
cat<<EOF
|
|
apps, List your apps
|
|
apps:create <app>, Create a new app
|
|
apps:destroy <app>, Permanently destroy an app
|
|
EOF
|
|
;;
|
|
|
|
*)
|
|
exit $DOKKU_NOT_IMPLEMENTED_EXIT
|
|
;;
|
|
|
|
esac
|