implement core plugin mgmt using plugn. add tests.
This commit is contained in:
committed by
Jose Diaz-Gonzalez
parent
d6341e9ab7
commit
8095df79f6
14
Makefile
14
Makefile
@@ -7,7 +7,6 @@ PREBUILT_STACK_URL ?= gliderlabs/herokuish:latest
|
||||
DOKKU_LIB_ROOT ?= /var/lib/dokku
|
||||
PLUGINS_PATH ?= ${DOKKU_LIB_ROOT}/plugins
|
||||
CORE_PLUGINS_PATH ?= ${DOKKU_LIB_ROOT}/core-plugins
|
||||
DISABLED_PLUGINS_PATH ?= ${DOKKU_LIB_ROOT}/disabled-plugins
|
||||
|
||||
# If the first argument is "vagrant-dokku"...
|
||||
ifeq (vagrant-dokku,$(firstword $(MAKECMDGOALS)))
|
||||
@@ -47,18 +46,21 @@ packer:
|
||||
|
||||
copyfiles:
|
||||
cp dokku /usr/local/bin/dokku
|
||||
mkdir -p ${CORE_PLUGINS_PATH} ${PLUGINS_PATH} ${DISABLED_PLUGINS_PATH}
|
||||
mkdir -p ${CORE_PLUGINS_PATH} ${PLUGINS_PATH}
|
||||
rm -rf ${CORE_PLUGINS_PATH}/*
|
||||
test -d ${CORE_PLUGINS_PATH}/enabled || PLUGIN_PATH=${CORE_PLUGINS_PATH} plugn init
|
||||
test -d ${PLUGINS_PATH}/enabled || PLUGIN_PATH=${PLUGINS_PATH} plugn init
|
||||
find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do \
|
||||
rm -Rf ${CORE_PLUGINS_PATH}/available/$$plugin && \
|
||||
rm -Rf ${PLUGINS_PATH}/available/$$plugin && \
|
||||
rm -Rf ${CORE_PLUGINS_PATH}/$$plugin && \
|
||||
rm -rf ${CORE_PLUGINS_PATH}/$$plugin && \
|
||||
rm -rf ${PLUGINS_PATH}/$$plugin && \
|
||||
cp -R plugins/$$plugin ${CORE_PLUGINS_PATH} && \
|
||||
ln -s ${CORE_PLUGINS_PATH}/$$plugin ${PLUGINS_PATH}/available; \
|
||||
cp -R plugins/$$plugin ${CORE_PLUGINS_PATH}/available && \
|
||||
ln -s ${CORE_PLUGINS_PATH}/available/$$plugin ${PLUGINS_PATH}/available; \
|
||||
PLUGIN_PATH=${CORE_PLUGINS_PATH} plugn enable $$plugin ;\
|
||||
PLUGIN_PATH=${PLUGINS_PATH} plugn enable $$plugin ;\
|
||||
done
|
||||
chown dokku:dokku -R ${PLUGINS_PATH} ${CORE_PLUGINS_PATH} ${DISABLED_PLUGINS_PATH}
|
||||
chown dokku:dokku -R ${PLUGINS_PATH} ${CORE_PLUGINS_PATH}
|
||||
$(MAKE) addman
|
||||
|
||||
addman:
|
||||
|
||||
12
dokku
12
dokku
@@ -8,8 +8,12 @@ export DOKKU_ROOT=${DOKKU_ROOT:=~dokku}
|
||||
export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"}
|
||||
|
||||
export PLUGIN_PATH=${PLUGIN_PATH:="$DOKKU_LIB_ROOT/plugins"}
|
||||
export PLUGIN_AVAILABLE_PATH=${PLUGIN_AVAILABLE_PATH:="$PLUGIN_PATH/available"}
|
||||
export PLUGIN_ENABLED_PATH=${PLUGIN_ENABLED_PATH:="$PLUGIN_PATH/enabled"}
|
||||
export PLUGIN_CORE_PATH=${PLUGIN_CORE_PATH:="$DOKKU_LIB_ROOT/core-plugins"}
|
||||
export PLUGIN_DISABLED_PATH=${PLUGIN_DISABLED_PATH:="$DOKKU_LIB_ROOT/disabled-plugins"}
|
||||
export PLUGIN_CORE_AVAILABLE_PATH=${PLUGIN_CORE_AVAILABLE_PATH:="$PLUGIN_CORE_PATH/available"}
|
||||
export PLUGIN_CORE_ENABLED_PATH=${PLUGIN_CORE_ENABLED_PATH:="$PLUGIN_CORE_PATH/enabled"}
|
||||
|
||||
export DOKKU_API_VERSION=1
|
||||
export DOKKU_NOT_IMPLEMENTED_EXIT=10
|
||||
export DOKKU_VALID_EXIT=0
|
||||
@@ -17,7 +21,7 @@ export DOKKU_VALID_EXIT=0
|
||||
export DOKKU_LOGS_DIR=${DOKKU_LOGS_DIR:="/var/log/dokku"}
|
||||
export DOKKU_EVENTS_LOGFILE=${DOKKU_EVENTS_LOGFILE:="$DOKKU_LOGS_DIR/events.log"}
|
||||
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
[[ -f $DOKKU_ROOT/dokkurc ]] && source $DOKKU_ROOT/dokkurc
|
||||
[[ -d $DOKKU_ROOT/.dokkurc ]] && for f in $DOKKU_ROOT/.dokkurc/*; do source $f; done
|
||||
@@ -37,7 +41,7 @@ if [[ "${args[0]}" =~ ^--.* ]]; then
|
||||
fi
|
||||
! has_tty && DOKKU_QUIET_OUTPUT=1
|
||||
|
||||
if [[ $(id -un) != "dokku" && $1 != plugin:install* && $1 != "plugin:update" ]]; then
|
||||
if [[ $(id -un) != "dokku" && $1 != plugin:*install* && $1 != "plugin:update" ]]; then
|
||||
sudo -u dokku -E -H $0 "$@"
|
||||
exit
|
||||
fi
|
||||
@@ -219,7 +223,7 @@ EOF
|
||||
|
||||
*)
|
||||
implemented=0
|
||||
for script in $PLUGIN_PATH/enabled/*/commands; do
|
||||
for script in $PLUGIN_ENABLED_PATH/*/commands; do
|
||||
set +e; $script "$@" ; exit_code=$? ; set -e
|
||||
if [[ "$exit_code" -eq "$DOKKU_NOT_IMPLEMENTED_EXIT" ]]; then
|
||||
continue
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
|
||||
case "$1" in
|
||||
build)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
PLUGIN_DIR="$(dirname $0)"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
[[ ! "$DOKKU_EVENTS" ]] || dokku_log_plugn_trigger_call "$(basename $0)" "$@"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
DOKKU_RSYSLOG_FILTER=/etc/rsyslog.d/99-dokku.conf
|
||||
DOKKU_LOGROTATE_FILE=/etc/logrotate.d/dokku
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
Please note that the hooks in Dokku are experimental and are likely to change quite a bit.
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
case "$1" in
|
||||
apps)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
APP="$1"; IMAGE_REPO=$(get_app_image_repo $APP)
|
||||
[[ -n $APP ]] && rm -rf "$DOKKU_ROOT/$APP" > /dev/null
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG); CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
||||
verify_app_name "$APP"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
|
||||
APP="$1"; IMAGE=$(get_app_image_name $APP); BUILD_ENV=""
|
||||
verify_app_name "$APP"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/certs/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/certs/functions"
|
||||
|
||||
is_tar_import() {
|
||||
[[ -t 0 ]] && return 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
# returns 'global', 'app', 'false'
|
||||
# if both are configured, app trumps global
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
#
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
|
||||
APP="$1"; DOKKU_APP_CONTAINER_ID="$2"; DOKKU_APP_CONTAINER_TYPE="$3"; DOKKU_APP_LISTEN_PORT="$4"; DOKKU_APP_LISTEN_IP="$5"
|
||||
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
|
||||
case "$1" in
|
||||
config)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
|
||||
STDIN=$(cat); APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||
DOCKERFILE_ENV_FILE="$DOKKU_ROOT/$APP/DOCKERFILE_ENV_FILE"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
config_export() {
|
||||
local CONFIG_TYPE="$1"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
PHASES=(build deploy run)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_PATH/available/domains/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/domains/functions"
|
||||
|
||||
RE_IPV4="([0-9]{1,3}[\.]){3}[0-9]{1,3}"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
get_app_domains() {
|
||||
local APP=$1; verify_app_name $APP
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
case "$1" in
|
||||
enter)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
git_build_app_repo() {
|
||||
verify_app_name "$1"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
APP="$1"; REV="$2"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
|
||||
APP="$1"
|
||||
NO_VHOST=$(config_get $APP NO_VHOST || true)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/certs/functions"
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_PATH/available/domains/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/certs/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/domains/functions"
|
||||
|
||||
validate_nginx () {
|
||||
set +e
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/config/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||
|
||||
APP="$1"
|
||||
if [[ -f "$DOKKU_ROOT/$APP/IP.web.1" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT.web.1" ]]; then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
APP="$1"
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/plugin/functions"
|
||||
|
||||
case "$1" in
|
||||
plugin)
|
||||
@@ -8,10 +9,20 @@ case "$1" in
|
||||
;;
|
||||
|
||||
plugin:install)
|
||||
if [[ $2 == "--core" ]]; then
|
||||
export PLUGIN_PATH="$PLUGIN_CORE_PATH"
|
||||
fi
|
||||
plugn trigger install
|
||||
case "$2" in
|
||||
--core)
|
||||
[[ "$#" -gt 2 ]] && dokku_log_info1_quiet "Cannot install additional core plugins, running core plugin install trigger"
|
||||
PLUGIN_PATH="$PLUGIN_CORE_PATH" plugn trigger install
|
||||
;;
|
||||
https:*|git:*)
|
||||
PLUGIN_GIT_URL="$2"
|
||||
download_and_enable_plugin $PLUGIN_GIT_URL
|
||||
plugn trigger install
|
||||
;;
|
||||
*)
|
||||
plugn trigger install
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
plugin:install-dependencies)
|
||||
@@ -22,34 +33,45 @@ case "$1" in
|
||||
;;
|
||||
|
||||
plugin:update)
|
||||
plugn trigger update
|
||||
case "$2" in
|
||||
https:*|git:*)
|
||||
PLUGIN_GIT_URL="$2"
|
||||
download_and_enable_plugin $PLUGIN_GIT_URL
|
||||
plugn trigger update
|
||||
;;
|
||||
*)
|
||||
plugn trigger update
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
plugins:disable)
|
||||
plugin:disable)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to disable"
|
||||
PLUGIN="$2"
|
||||
[[ -e $PLUGIN_CORE_PATH/$PLUGIN ]] && echo "Cannot disable a core plugin" && exit 1
|
||||
[[ -e $PLUGIN_DISABLED_PATH/$PLUGIN ]] && echo "Plugin already disabled" && exit 1
|
||||
[[ ! -e $PLUGIN_PATH/$PLUGIN ]] && echo "Plugin does not exist" && exit 1
|
||||
mv "$PLUGIN_PATH/$PLUGIN" "$PLUGIN_DISABLED_PATH"
|
||||
echo "Plugin $PLUGIN disabled"
|
||||
disable_plugin "$PLUGIN"
|
||||
;;
|
||||
|
||||
plugins:enable)
|
||||
plugin:enable)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable"
|
||||
PLUGIN="$2"
|
||||
[[ -e $PLUGIN_PATH/$PLUGIN ]] && echo "Plugin already enabled" && exit 1
|
||||
[[ ! -e $PLUGIN_DISABLED_PATH/$PLUGIN ]] && echo "Plugin does not exist" && exit 1
|
||||
mv "$PLUGIN_DISABLED_PATH/$PLUGIN" "$PLUGIN_PATH"
|
||||
echo "Plugin $PLUGIN enabled"
|
||||
enable_plugin "$PLUGIN"
|
||||
;;
|
||||
|
||||
help | ps:help)
|
||||
plugin:uninstall)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable"
|
||||
PLUGIN="$2"
|
||||
uninstall_plugin "$PLUGIN"
|
||||
;;
|
||||
|
||||
help | plugin:help)
|
||||
cat<<EOF
|
||||
plugin, Print active plugins
|
||||
plugin:install [--core], Install active plugins (or only core ones)
|
||||
plugin:install-dependencies [--core], Install active plugins dependencies (or only core ones)
|
||||
plugin:update, Update active plugins
|
||||
plugin:install [--core|git-url], Optionally download git-url & run install trigger for active plugins (or only core ones)
|
||||
plugin:install-dependencies [--core], Run install-dependencies trigger for active plugins (or only core ones)
|
||||
plugin:update [git-url], Optionally download git-url & run update trigger for active plugins
|
||||
plugin:enable <name>, Enable a previously disabled plugin
|
||||
plugin:disable <name>, Disable an installed plugin (third-party only)
|
||||
plugin:uninstall <name>, Uninstall a plugin (third-party only)
|
||||
EOF
|
||||
;;
|
||||
|
||||
|
||||
41
plugins/plugin/functions
Executable file
41
plugins/plugin/functions
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
disable_plugin() {
|
||||
local PLUGIN="$1"
|
||||
[[ -e $PLUGIN_CORE_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Cannot disable a core plugin"
|
||||
[[ ! -e $PLUGIN_ENABLED_PATH/$PLUGIN ]] && dokku_log_fail "Plugin already disabled"
|
||||
[[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin does not exist"
|
||||
plugn disable $PLUGIN
|
||||
dokku_log_info1_quiet "Plugin $PLUGIN disabled"
|
||||
}
|
||||
|
||||
enable_plugin() {
|
||||
local PLUGIN="$1"
|
||||
[[ -e $PLUGIN_ENABLED_PATH/$PLUGIN ]] && dokku_log_fail "Plugin already enabled"
|
||||
[[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin does not exist"
|
||||
plugn enable $PLUGIN
|
||||
dokku_log_info1_quiet "Plugin $PLUGIN enabled"
|
||||
}
|
||||
|
||||
download_plugin() {
|
||||
local PLUGIN_GIT_URL="$1"
|
||||
plugn install $PLUGIN_GIT_URL
|
||||
}
|
||||
|
||||
download_and_enable_plugin() {
|
||||
local PLUGIN_GIT_URL="$1"
|
||||
local PLUGIN_NAME=$(echo $PLUGIN_GIT_URL | awk -F '/' '{ print $NF }' | sed -e "s:.git::g")
|
||||
dokku_log_info1_quiet "Cloning plugin repo $PLUGIN_GIT_URL to $PLUGIN_AVAILABLE_PATH/$PLUGIN_NAME"
|
||||
download_plugin $PLUGIN_GIT_URL
|
||||
enable_plugin $PLUGIN_NAME
|
||||
}
|
||||
|
||||
uninstall_plugin() {
|
||||
local PLUGIN_NAME="$1"
|
||||
[[ -e $PLUGIN_CORE_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Cannot uninstall a core plugin"
|
||||
[[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin does not exist"
|
||||
plugn uninstall $PLUGIN_NAME
|
||||
dokku_log_info1_quiet "Plugin $PLUGIN uninstalled"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/ps/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/ps/functions"
|
||||
|
||||
case "$1" in
|
||||
ps)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
print_dokku_scale_file() {
|
||||
local APP="$1"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/ps/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/ps/functions"
|
||||
|
||||
APP="$1"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_PATH/available/tags/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/tags/functions"
|
||||
|
||||
case "$1" in
|
||||
tags)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
tag_image() {
|
||||
docker tag -f "$1" "$2"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
case "$1" in
|
||||
tar-from|tar:from)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
APP="$1"; REV="$2"
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ check_urls() {
|
||||
}
|
||||
|
||||
@test "(core) port exposure (dockerfile raw port)" {
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
cat<<EOF > $DOCKERFILE
|
||||
EXPOSE 3001/udp
|
||||
EXPOSE 3003
|
||||
@@ -178,7 +178,7 @@ EOF
|
||||
}
|
||||
|
||||
@test "(core) port exposure (dockerfile tcp port)" {
|
||||
source "$PLUGIN_PATH/available/common/functions"
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
cat<<EOF > $DOCKERFILE
|
||||
EXPOSE 3001/udp
|
||||
EXPOSE 3000/tcp
|
||||
|
||||
45
tests/unit/plugin.bats
Normal file
45
tests/unit/plugin.bats
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
TEST_PLUGIN_NAME=smoke-test-plugin
|
||||
TEST_PLUGIN_GIT_REPO=https://github.com/dokku/${TEST_PLUGIN_NAME}.git
|
||||
|
||||
remove_test_plugin() {
|
||||
rm -rf $PLUGIN_ENABLED_PATH/$TEST_PLUGIN_NAME $PLUGIN_AVAILABLE_PATH/$TEST_PLUGIN_NAME
|
||||
}
|
||||
|
||||
teardown() {
|
||||
remove_test_plugin || true
|
||||
}
|
||||
|
||||
@test "(plugin) plugin:install, plugin:disable, plugin:uninstall" {
|
||||
run bash -c "dokku plugin:install $TEST_PLUGIN_GIT_REPO"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku plugin | grep enabled | grep $TEST_PLUGIN_NAME"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku plugin:disable $TEST_PLUGIN_NAME"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku plugin | grep disabled | grep $TEST_PLUGIN_NAME"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku plugin:uninstall $TEST_PLUGIN_NAME"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku plugin | grep $TEST_PLUGIN_NAME"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
}
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
# constants
|
||||
DOKKU_ROOT=${DOKKU_ROOT:=~dokku}
|
||||
PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"}
|
||||
DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"}
|
||||
PLUGIN_PATH=${PLUGIN_PATH:="$DOKKU_LIB_ROOT/plugins"}
|
||||
PLUGIN_AVAILABLE_PATH=${PLUGIN_AVAILABLE_PATH:="$PLUGIN_PATH/available"}
|
||||
PLUGIN_ENABLED_PATH=${PLUGIN_ENABLED_PATH:="$PLUGIN_PATH/enabled"}
|
||||
PLUGIN_CORE_PATH=${PLUGIN_CORE_PATH:="$DOKKU_LIB_ROOT/core-plugins"}
|
||||
PLUGIN_CORE_AVAILABLE_PATH=${PLUGIN_CORE_AVAILABLE_PATH:="$PLUGIN_CORE_PATH/available"}
|
||||
TEST_APP=my-cool-guy-test-app
|
||||
|
||||
# test functions
|
||||
|
||||
Reference in New Issue
Block a user