refactor: use only a single implementation for cache purging

This change moves cache clearing into the repo plugin, and standardizes on a single way of clearing the cache.
This commit is contained in:
Jose Diaz-Gonzalez
2019-07-05 16:12:22 -04:00
parent 33423a0508
commit 69e4cd7c44
5 changed files with 71 additions and 46 deletions

View File

@@ -1,21 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
apps_pre_delete() {
declare desc="apps pre-delete plugin trigger"
local trigger="apps_pre_delete"
local APP="$1"
local IMAGE_TAG="$2"
local CACHE_DIR="$DOKKU_ROOT/$APP/cache"
local CACHE_HOST_DIR="$DOKKU_HOST_ROOT/$APP/cache"
verify_app_name "$APP"
if [[ -d $CACHE_DIR ]]; then
DOKKU_IMAGE="$(config_get "$APP" DOKKU_IMAGE || echo "$DOKKU_IMAGE")"
"$DOCKER_BIN" run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$CACHE_HOST_DIR:/cache" "$DOKKU_IMAGE" find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; || true
fi
}
apps_pre_delete "$@"