feat: add ability to check if a plugin has been installed

This commit is contained in:
Jose Diaz-Gonzalez
2020-04-01 11:48:28 -04:00
parent 75a9b2a4d2
commit b70e59f9ff
4 changed files with 32 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
plugin:disable <name> # Disable an installed plugin (third-party only)
plugin:enable <name> # Enable a previously disabled plugin
plugin:install [--core|git-url [--committish tag|branch|commit|--name custom-plugin-name]] # Optionally download git-url (with custom tag/committish) & run install trigger for active plugins (or only core ones)
plugin:installed <name> # Checks if a plugin is installed
plugin:install-dependencies [--core] # Run install-dependencies trigger for active plugins (or only core ones)
plugin:list # Print active plugins
plugin:trigger <args...>. # Trigger an arbitrary plugin hook
@@ -63,6 +64,12 @@ plugn: dev
trace 0.20.0 enabled dokku core trace plugin
```
You can check if a plugin has been installed via the `pluginn:installed` command:
```shell
dokku plugin:install postgres
```
Installing a plugin is easy as well using the `plugin:install` command. This command will also trigger the `install` pluginhook on all existing plugins.
```shell

View File

@@ -12,6 +12,15 @@ cmd-plugin-list() {
plugn list
}
cmd-plugin-installed() {
declare desc="checks if a plugin is installed"
declare cmd="plugin:installed"
[[ "$1" == "$cmd" ]] && shift 1
declare PLUGIN_NAME="$1"
plugn list | awk '{print $1}' | grep -q "^${PLUGIN_NAME}$"
}
plugin_prime_bash_completion() {
declare desc="primes the bash-completion cache"

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/plugin/internal-functions"
cmd-plugin-installed "$@"

View File

@@ -39,11 +39,21 @@ teardown() {
}
@test "(plugin) plugin:install, plugin:disable, plugin:update plugin:uninstall" {
run /bin/bash -c "dokku plugin:installed $TEST_PLUGIN_NAME"
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku plugin:install $TEST_PLUGIN_GIT_REPO --name $TEST_PLUGIN_NAME"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku plugin:installed $TEST_PLUGIN_NAME"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku plugin:update $TEST_PLUGIN_NAME"
echo "output: $output"
echo "status: $status"