From c4c7886037f816460c9ac74c267bf9e56a9126cf Mon Sep 17 00:00:00 2001 From: Josh Manders Date: Thu, 17 Nov 2016 12:55:08 -0600 Subject: [PATCH 1/3] add plugin uninstall trigger --- docs/development/plugin-triggers.md | 15 +++++++++++++++ plugins/plugin/functions | 1 + 2 files changed, 16 insertions(+) diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 846c6fecd..b19d8f184 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -866,6 +866,21 @@ APP="$1"; IMAGE_TAG="$2" some code to remove a docker hub tag because it's not implemented in the CLI.... ``` +### `uninstall` + - Description: Used to cleanup after itself. + - Invoked by: `dokku plugin:uninstall` + - Arguments: None + - Example: + + ```shell + #!/usr/bin/env bash + # Cleanup up extra containers created + + set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + + docker rmi -f "${PLUGIN_IMAGE_DEPENDENCY}" + ``` + ### `update` - Description: Can be used to run plugin updates on a regular interval. You can schedule the invoker in a cron-task to ensure your system gets regular updates. diff --git a/plugins/plugin/functions b/plugins/plugin/functions index be9bf6d16..abed5c29b 100755 --- a/plugins/plugin/functions +++ b/plugins/plugin/functions @@ -70,6 +70,7 @@ uninstall_plugin() { local PLUGIN="$1" [[ -e $PLUGIN_CORE_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Cannot uninstall a core plugin" [[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin ($PLUGIN) is not currently installed" + plugn trigger uninstall plugn uninstall "$PLUGIN" dokku_log_info1_quiet "Plugin $PLUGIN uninstalled" } From d4475e582d399d26c8a7870edcf48ef760cba0f8 Mon Sep 17 00:00:00 2001 From: Josh Manders Date: Thu, 17 Nov 2016 16:06:57 -0600 Subject: [PATCH 2/3] pass plugin to uninstall --- docs/development/plugin-triggers.md | 6 ++++-- plugins/plugin/functions | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index b19d8f184..27fd3c6f4 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -869,7 +869,7 @@ some code to remove a docker hub tag because it's not implemented in the CLI.... ### `uninstall` - Description: Used to cleanup after itself. - Invoked by: `dokku plugin:uninstall` - - Arguments: None + - Arguments: `$PLUGIN` - Example: ```shell @@ -878,7 +878,9 @@ some code to remove a docker hub tag because it's not implemented in the CLI.... set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x - docker rmi -f "${PLUGIN_IMAGE_DEPENDENCY}" + PLUGIN="$1" + + [[ "$PLUGIN" = "my-plugin" ]] && docker rmi -f "${PLUGIN_IMAGE_DEPENDENCY}" ``` ### `update` diff --git a/plugins/plugin/functions b/plugins/plugin/functions index abed5c29b..3b814d7f8 100755 --- a/plugins/plugin/functions +++ b/plugins/plugin/functions @@ -70,7 +70,7 @@ uninstall_plugin() { local PLUGIN="$1" [[ -e $PLUGIN_CORE_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Cannot uninstall a core plugin" [[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin ($PLUGIN) is not currently installed" - plugn trigger uninstall + plugn trigger uninstall "$PLUGIN" plugn uninstall "$PLUGIN" dokku_log_info1_quiet "Plugin $PLUGIN uninstalled" } From 63817fc6f396b0404281028c6e24f370255d84a9 Mon Sep 17 00:00:00 2001 From: Josh Manders Date: Sun, 20 Nov 2016 17:49:02 -0600 Subject: [PATCH 3/3] add warning --- docs/development/plugin-triggers.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 27fd3c6f4..d8d8fdced 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -867,6 +867,7 @@ some code to remove a docker hub tag because it's not implemented in the CLI.... ``` ### `uninstall` + - Description: Used to cleanup after itself. - Invoked by: `dokku plugin:uninstall` - Arguments: `$PLUGIN` @@ -883,6 +884,8 @@ some code to remove a docker hub tag because it's not implemented in the CLI.... [[ "$PLUGIN" = "my-plugin" ]] && docker rmi -f "${PLUGIN_IMAGE_DEPENDENCY}" ``` + > To avoid uninstalling other plugins make sure to check the plugin name like shown in the example. + ### `update` - Description: Can be used to run plugin updates on a regular interval. You can schedule the invoker in a cron-task to ensure your system gets regular updates.