Files
dokku/plugins/scheduler-docker-local/post-delete
Jose Diaz-Gonzalez 4aaefb0c4c fix: implement missing cleanup routines
Without these, there was potential for configuration for certain plugins to continue to exist after an app was deleted.
2020-12-02 03:27:06 -05:00

35 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
trigger-scheduler-docker-local-post-delete() {
declare desc="scheduler-docker-local post-delete plugin trigger"
declare trigger="post-delete"
declare APP="$1"
fn-plugin-property-destroy "scheduler-docker-local" "$APP"
rm -rf "${DOKKU_LIB_ROOT}/data/scheduler-docker-local/$APP"
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
return
fi
local IMAGE_REPO=$(get_app_image_repo "$APP")
# remove all application containers & images
# shellcheck disable=SC2046
local DOKKU_APP_CIDS=$("$DOCKER_BIN" container list --all --no-trunc | grep "dokku/${APP}:" | awk '{ print $1 }' | xargs)
if [[ -n "$DOKKU_APP_CIDS" ]]; then
# shellcheck disable=SC2086
"$DOCKER_BIN" container rm --force $DOKKU_APP_CIDS >/dev/null 2>&1 || true
fi
# shellcheck disable=SC2046
"$DOCKER_BIN" image rm $("$DOCKER_BIN" image list --quiet "$IMAGE_REPO" | xargs) &>/dev/null || true
}
trigger-scheduler-docker-local-post-delete "$@"