Merge pull request #6630 from dokku/cleanup-cache-dir-code
Remove unused code for copying cache directories
This commit is contained in:
10 files changed
+110
-55
No files matched your search
@@ -1,26 +0,0 @@
|
|||||||
#!/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-builder-herokuish-post-app-clone-setup() {
|
|
||||||
declare desc="builder-herokuish post-app-clone-setup plugin trigger"
|
|
||||||
declare trigger="post-app-clone-setup"
|
|
||||||
declare OLD_APP="$1" NEW_APP="$2"
|
|
||||||
|
|
||||||
local NEW_CACHE_DIR="$DOKKU_ROOT/$NEW_APP/cache"
|
|
||||||
local NEW_CACHE_HOST_DIR="$DOKKU_HOST_ROOT/$NEW_APP/cache"
|
|
||||||
|
|
||||||
pushd "$DOKKU_ROOT/$OLD_APP/." >/dev/null
|
|
||||||
find ./* \( -name ".cache" -o -name "cache" \) -prune -o -print | cpio -pdmu --quiet "$DOKKU_ROOT/$NEW_APP"
|
|
||||||
popd &>/dev/null || pushd "/tmp" >/dev/null
|
|
||||||
|
|
||||||
if [[ -d "$NEW_CACHE_DIR" ]] && ! rmdir "$NEW_CACHE_DIR"; then
|
|
||||||
local DOCKER_RUN_LABEL_ARGS="--label=com.dokku.app-name=$NEW_APP"
|
|
||||||
"$DOCKER_BIN" container run "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS --rm --volume "$NEW_CACHE_HOST_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
|
|
||||||
fi
|
|
||||||
rm -rf "$NEW_CACHE_DIR"
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger-builder-herokuish-post-app-clone-setup "$@"
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/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-builder-herokuish-post-app-clone-setup() {
|
|
||||||
declare desc="builder-herokuish post-app-clone-setup plugin trigger"
|
|
||||||
declare trigger="post-app-clone-setup"
|
|
||||||
declare OLD_APP="$1" NEW_APP="$2"
|
|
||||||
|
|
||||||
local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache"
|
|
||||||
local OLD_CACHE_HOST_DIR="$DOKKU_HOST_ROOT/$OLD_APP/cache"
|
|
||||||
|
|
||||||
if [[ -d "$OLD_CACHE_DIR" ]] && ! rmdir "$OLD_CACHE_DIR" &>/dev/null; then
|
|
||||||
local DOCKER_RUN_LABEL_ARGS="--label=com.dokku.app-name=$NEW_APP"
|
|
||||||
"$DOCKER_BIN" container run "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS --rm --volume "$OLD_CACHE_HOST_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
|
|
||||||
fi
|
|
||||||
rm -rf "$OLD_CACHE_DIR"
|
|
||||||
|
|
||||||
pushd "$DOKKU_ROOT/$OLD_APP/." >/dev/null
|
|
||||||
find ./* \( -name ".cache" -o -name "cache" \) -prune -o -print | cpio -pdmu --quiet "$DOKKU_ROOT/$NEW_APP"
|
|
||||||
popd &>/dev/null || pushd "/tmp" >/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger-builder-herokuish-post-app-clone-setup "$@"
|
|
||||||
@@ -4,3 +4,4 @@
|
|||||||
/triggers
|
/triggers
|
||||||
/config-*
|
/config-*
|
||||||
/config_sub
|
/config_sub
|
||||||
|
/post-*
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
GOARCH ?= amd64
|
GOARCH ?= amd64
|
||||||
SUBCOMMANDS = subcommands/bundle subcommands/clear subcommands/export subcommands/get subcommands/keys subcommands/show subcommands/set subcommands/unset
|
SUBCOMMANDS = subcommands/bundle subcommands/clear subcommands/export subcommands/get subcommands/keys subcommands/show subcommands/set subcommands/unset
|
||||||
TRIGGERS = triggers/config-export triggers/config-get triggers/config-get-global
|
TRIGGERS = triggers/config-export triggers/config-get triggers/config-get-global triggers/post-app-clone-setup triggers/post-app-rename-setup
|
||||||
BUILD = commands config_sub subcommands triggers
|
BUILD = commands config_sub subcommands triggers
|
||||||
PLUGIN_NAME = config
|
PLUGIN_NAME = config
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ func main() {
|
|||||||
case "config-get-global":
|
case "config-get-global":
|
||||||
key := flag.Arg(0)
|
key := flag.Arg(0)
|
||||||
err = config.TriggerConfigGetGlobal(key)
|
err = config.TriggerConfigGetGlobal(key)
|
||||||
|
case "post-app-clone-setup":
|
||||||
|
oldAppName := flag.Arg(0)
|
||||||
|
newAppName := flag.Arg(1)
|
||||||
|
err = config.TriggerPostAppCloneSetup(oldAppName, newAppName)
|
||||||
|
case "post-app-rename-setup":
|
||||||
|
oldAppName := flag.Arg(0)
|
||||||
|
newAppName := flag.Arg(1)
|
||||||
|
err = config.TriggerPostAppRenameSetup(oldAppName, newAppName)
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("Invalid plugin trigger call: %s", trigger)
|
err = fmt.Errorf("Invalid plugin trigger call: %s", trigger)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,3 +44,43 @@ func TriggerConfigGetGlobal(key string) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TriggerPostAppCloneSetup creates new buildpacks files
|
||||||
|
func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
||||||
|
oldEnv, err := LoadAppEnv(oldAppName)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Unable to load old environment: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
newEnv, err := LoadAppEnv(newAppName)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Unable to load new environment: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
newEnv.Merge(oldEnv)
|
||||||
|
if err := newEnv.Write(); err != nil {
|
||||||
|
return fmt.Errorf("Unable to write new environment: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TriggerPostAppRenameSetup renames buildpacks files
|
||||||
|
func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
|
||||||
|
oldEnv, err := LoadAppEnv(oldAppName)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Unable to load old environment: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
newEnv, err := LoadAppEnv(newAppName)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Unable to load new environment: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
newEnv.Merge(oldEnv)
|
||||||
|
if err := newEnv.Write(); err != nil {
|
||||||
|
return fmt.Errorf("Unable to write new environment: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Executable
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||||
|
|
||||||
|
trigger-docker-options-post-app-clone-setup() {
|
||||||
|
declare desc="copies docker options over"
|
||||||
|
declare trigger="post-app-clone-setup"
|
||||||
|
declare OLD_APP="$1" NEW_APP="$2"
|
||||||
|
|
||||||
|
declare -a phases
|
||||||
|
phases=("build" "deploy" "run")
|
||||||
|
for phase in "${phases[@]}"; do
|
||||||
|
if [[ -f "$(fn-get-phase-file-path "$OLD_APP" "$phase")" ]]; then
|
||||||
|
cp "$(fn-get-phase-file-path "$OLD_APP" "$phase")" "$(fn-get-phase-file-path "$NEW_APP" "$phase")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger-docker-options-post-app-clone-setup "$@"
|
||||||
Executable
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||||
|
|
||||||
|
trigger-docker-options-post-app-rename-setup() {
|
||||||
|
declare desc="copies docker options over"
|
||||||
|
declare trigger="post-app-rename-setup"
|
||||||
|
declare OLD_APP="$1" NEW_APP="$2"
|
||||||
|
|
||||||
|
declare -a phases
|
||||||
|
phases=("build" "deploy" "run")
|
||||||
|
for phase in "${phases[@]}"; do
|
||||||
|
if [[ -f "$(fn-get-phase-file-path "$OLD_APP" "$phase")" ]]; then
|
||||||
|
cp "$(fn-get-phase-file-path "$OLD_APP" "$phase")" "$(fn-get-phase-file-path "$NEW_APP" "$phase")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger-docker-options-post-app-rename-setup "$@"
|
||||||
@@ -7,9 +7,9 @@ trigger-domains-post-app-rename-setup() {
|
|||||||
declare trigger="post-app-rename-setup"
|
declare trigger="post-app-rename-setup"
|
||||||
declare OLD_APP="$1" NEW_APP="$2"
|
declare OLD_APP="$1" NEW_APP="$2"
|
||||||
|
|
||||||
if [[ -f "$DOKKU_ROOT/$NEW_APP/VHOST" ]]; then
|
if [[ -f "$DOKKU_ROOT/$OLD_APP/VHOST" ]]; then
|
||||||
while read -r VHOST || [[ -n "$VHOST" ]]; do
|
while read -r VHOST || [[ -n "$VHOST" ]]; do
|
||||||
sed -i -e "s/$OLD_APP.$VHOST/$NEW_APP.$VHOST/g" "$DOKKU_ROOT/$NEW_APP/VHOST"
|
sed -e "s/$OLD_APP.$VHOST/$NEW_APP.$VHOST/g" "$DOKKU_ROOT/$OLD_APP/VHOST" >"$DOKKU_ROOT/$NEW_APP/VHOST"
|
||||||
done <"$DOKKU_ROOT/VHOST"
|
done <"$DOKKU_ROOT/VHOST"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,14 @@ teardown() {
|
|||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart $TEST_APP KEY=VALUE-$TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options:add $TEST_APP deploy --no-healthcheck"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
run /bin/bash -c "dokku git:set $TEST_APP deploy-branch SOME_BRANCH_NAME"
|
run /bin/bash -c "dokku git:set $TEST_APP deploy-branch SOME_BRANCH_NAME"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
@@ -204,6 +212,16 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
assert_output "https://github.com/heroku/heroku-buildpack-ruby.git"
|
assert_output "https://github.com/heroku/heroku-buildpack-ruby.git"
|
||||||
|
run /bin/bash -c "dokku config:get great-test-name KEY"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "VALUE-$TEST_APP"
|
||||||
|
run /bin/bash -c "dokku docker-options:report great-test-name --docker-options-deploy"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains "--no-healthcheck"
|
||||||
run /bin/bash -c "dokku git:report great-test-name --git-deploy-branch"
|
run /bin/bash -c "dokku git:report great-test-name --git-deploy-branch"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
|
|||||||
Reference in new issue
Block a user