#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"

trigger-scheduler-docker-local-post-app-clone-setup() {
  declare desc="removes docker-local files when setting up a clone"
  declare trigger="post-app-clone-setup"
  declare OLD_APP="$1" NEW_APP="$2"
  local APP_ROOT="$DOKKU_ROOT/$NEW_APP"

  fn-plugin-property-clone "scheduler-docker-local" "$OLD_APP" "$NEW_APP"
  pushd "$APP_ROOT" >/dev/null
  find "$APP_ROOT" -type f -name 'CONTAINER.*' -exec rm {} \;
  popd &>/dev/null || pushd "/tmp" >/dev/null
}

trigger-scheduler-docker-local-post-app-clone-setup "$@"
