1 parent
e64b69248a
commit
89cc896c27
3 files changed
+81
-2
No files matched your search
@@ -33,3 +33,33 @@ plugin_prime_bash_completion() {
|
|||||||
dokku_log_info1_quiet "Priming bash-completion cache"
|
dokku_log_info1_quiet "Priming bash-completion cache"
|
||||||
dokku --quiet help --all | awk '/^ /{ print $1 }' | sort >"/var/cache/dokku-completion"
|
dokku --quiet help --all | awk '/^ /{ print $1 }' | sort >"/var/cache/dokku-completion"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn-is-core-plugin() {
|
||||||
|
declare PLUGIN_NAME="$1"
|
||||||
|
|
||||||
|
if [[ -L "$PLUGIN_CORE_ENABLED_PATH/$PLUGIN_NAME" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn-is-valid-plugin() {
|
||||||
|
declare PLUGIN_NAME="$1"
|
||||||
|
|
||||||
|
if [[ "$PLUGIN_NAME" =~ ^[0-9a-zA-Z_-]+$ ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn-plugin-enabled() {
|
||||||
|
declare PLUGIN_NAME="$1"
|
||||||
|
|
||||||
|
if [[ -L "$PLUGIN_ENABLED_PATH/$PLUGIN_NAME" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
@@ -10,8 +10,21 @@ cmd-plugin-update() {
|
|||||||
declare PLUGIN="$1" PLUGIN_COMMITTISH="$2"
|
declare PLUGIN="$1" PLUGIN_COMMITTISH="$2"
|
||||||
|
|
||||||
if [[ -n "$PLUGIN" ]]; then
|
if [[ -n "$PLUGIN" ]]; then
|
||||||
|
if ! fn-is-valid-plugin "$PLUGIN"; then
|
||||||
|
dokku_log_fail "Invalid plugin name specified"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! fn-plugin-enabled "$PLUGIN"; then
|
||||||
|
dokku_log_fail "Specified plugin not enabled or installed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if fn-is-core-plugin "$PLUGIN"; then
|
||||||
|
dokku_log_fail "Cannot trigger plugin:update against core plugin, please update Dokku instead"
|
||||||
|
fi
|
||||||
|
|
||||||
plugn update "$PLUGIN" "$PLUGIN_COMMITTISH"
|
plugn update "$PLUGIN" "$PLUGIN_COMMITTISH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
plugn trigger update
|
plugn trigger update
|
||||||
plugin_prime_bash_completion
|
plugin_prime_bash_completion
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-2
@@ -42,7 +42,7 @@ teardown() {
|
|||||||
run /bin/bash -c "dokku plugin:installed $TEST_PLUGIN_NAME"
|
run /bin/bash -c "dokku plugin:installed $TEST_PLUGIN_NAME"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_failure
|
assert_failure
|
||||||
|
|
||||||
run /bin/bash -c "dokku plugin:install $TEST_PLUGIN_GIT_REPO --name $TEST_PLUGIN_NAME"
|
run /bin/bash -c "dokku plugin:install $TEST_PLUGIN_GIT_REPO --name $TEST_PLUGIN_NAME"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
@@ -52,7 +52,7 @@ teardown() {
|
|||||||
run /bin/bash -c "dokku plugin:installed $TEST_PLUGIN_NAME"
|
run /bin/bash -c "dokku plugin:installed $TEST_PLUGIN_NAME"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
run /bin/bash -c "dokku plugin:update $TEST_PLUGIN_NAME"
|
run /bin/bash -c "dokku plugin:update $TEST_PLUGIN_NAME"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
@@ -214,6 +214,42 @@ teardown() {
|
|||||||
assert_output_contains "dokku" "3"
|
assert_output_contains "dokku" "3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(plugin) plugin:update [errors]" {
|
||||||
|
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:disable $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"
|
||||||
|
assert_failure
|
||||||
|
assert_output_contains "Specified plugin not enabled or installed"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku plugin:update invalid"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
assert_output_contains "Specified plugin not enabled or installed"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku plugin:update $TEST_PLUGIN_GIT_REPO"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
assert_output_contains "Invalid plugin name specified"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku plugin:update app-json"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
assert_output_contains "please update Dokku instead"
|
||||||
|
}
|
||||||
|
|
||||||
@test "(plugin) plugin:update permissions set properly" {
|
@test "(plugin) plugin:update permissions set properly" {
|
||||||
run /bin/bash -c "ls -lah /var/lib/dokku/core-plugins/available/git/commands"
|
run /bin/bash -c "ls -lah /var/lib/dokku/core-plugins/available/git/commands"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
|
|||||||
Reference in new issue
Block a user