diff --git a/Makefile b/Makefile index 6ac803847..cb805223f 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ DOKKU_VERSION = master SSHCOMMAND_URL ?= https://raw.github.com/progrium/sshcommand/master/sshcommand -PLUGINHOOK_URL ?= https://s3.amazonaws.com/progrium-pluginhook/pluginhook_0.1.0_amd64.deb +PLUGN_URL ?= https://github.com/progrium/plugn/releases/download/v0.1.0/plugn_0.1.0_linux_x86_64.tgz STACK_URL ?= https://github.com/gliderlabs/herokuish.git PREBUILT_STACK_URL ?= gliderlabs/herokuish:latest -PLUGINS_PATH ?= /var/lib/dokku/plugins +DOKKU_LIB_ROOT ?= /var/lib/dokku +PLUGINS_PATH ?= ${DOKKU_LIB_ROOT}/plugins +CORE_PLUGINS_PATH ?= ${DOKKU_LIB_ROOT}/core-plugins # If the first argument is "vagrant-dokku"... ifeq (vagrant-dokku,$(firstword $(MAKECMDGOALS))) @@ -20,7 +22,7 @@ else BUILD_STACK_TARGETS = build-in-docker endif -.PHONY: all apt-update install version copyfiles man-db plugins dependencies sshcommand pluginhook docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku +.PHONY: all apt-update install version copyfiles man-db plugins dependencies sshcommand plugn docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku include tests.mk include deb.mk @@ -35,7 +37,7 @@ release: deb-all package_cloud packer package_cloud: package_cloud push dokku/dokku/ubuntu/trusty herokuish*.deb package_cloud push dokku/dokku/ubuntu/trusty sshcommand*.deb - package_cloud push dokku/dokku/ubuntu/trusty pluginhook*.deb + package_cloud push dokku/dokku/ubuntu/trusty plugn*.deb package_cloud push dokku/dokku/ubuntu/trusty rubygem*.deb package_cloud push dokku/dokku/ubuntu/trusty dokku*.deb @@ -44,13 +46,21 @@ packer: copyfiles: cp dokku /usr/local/bin/dokku - mkdir -p ${PLUGINS_PATH} - find ${PLUGINS_PATH} -mindepth 2 -maxdepth 2 -name '.core' -printf '%h\0' | xargs -0 rm -Rf + 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 ${PLUGINS_PATH}/$$plugin && \ - cp -R plugins/$$plugin ${PLUGINS_PATH} && \ - touch ${PLUGINS_PATH}/$$plugin/.core; \ + rm -Rf ${CORE_PLUGINS_PATH}/available/$$plugin && \ + rm -Rf ${PLUGINS_PATH}/available/$$plugin && \ + rm -rf ${CORE_PLUGINS_PATH}/$$plugin && \ + rm -rf ${PLUGINS_PATH}/$$plugin && \ + 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} $(MAKE) addman addman: @@ -61,13 +71,13 @@ addman: version: git describe --tags > ~dokku/VERSION 2> /dev/null || echo '~${DOKKU_VERSION} ($(shell date -uIminutes))' > ~dokku/VERSION -plugin-dependencies: pluginhook - dokku plugins-install-dependencies +plugin-dependencies: plugn + dokku plugin:install-dependencies --core -plugins: pluginhook docker - dokku plugins-install +plugins: plugn docker + dokku plugin:install --core -dependencies: apt-update sshcommand pluginhook docker help2man man-db +dependencies: apt-update sshcommand plugn docker help2man man-db $(MAKE) -e stack apt-update: @@ -84,9 +94,9 @@ sshcommand: chmod +x /usr/local/bin/sshcommand sshcommand create dokku /usr/local/bin/dokku -pluginhook: - wget -qO /tmp/pluginhook_0.1.0_amd64.deb ${PLUGINHOOK_URL} - dpkg -i /tmp/pluginhook_0.1.0_amd64.deb +plugn: + wget -qO /tmp/plugn_latest.tgz ${PLUGN_URL} + tar xzf /tmp/plugn_latest.tgz -C /usr/local/bin docker: aufs apt-get install -qq -y curl diff --git a/deb.mk b/deb.mk index 73d03bc52..ae7b28f90 100644 --- a/deb.mk +++ b/deb.mk @@ -8,11 +8,11 @@ DOKKU_DESCRIPTION = 'Docker powered mini-Heroku in around 100 lines of Bash' DOKKU_REPO_NAME ?= progrium/dokku DOKKU_ARCHITECTURE = amd64 -PLUGINHOOK_DESCRIPTION = 'Simple dispatcher and protocol for shell-based plugins, an improvement to hook scripts' -PLUGINHOOK_REPO_NAME ?= progrium/pluginhook -PLUGINHOOK_VERSION ?= 0.2.0 -PLUGINHOOK_ARCHITECTURE = amd64 -PLUGINHOOK_PACKAGE_NAME = pluginhook_$(PLUGINHOOK_VERSION)_$(PLUGINHOOK_ARCHITECTURE).deb +PLUGN_DESCRIPTION = 'Hook system that lets users extend your application with plugins' +PLUGN_REPO_NAME ?= progrium/plugn +PLUGN_VERSION ?= 0.1.0 +PLUGN_ARCHITECTURE = amd64 +PLUGN_PACKAGE_NAME = plugn_$(PLUGN_VERSION)_$(PLUGN_ARCHITECTURE).deb SSHCOMMAND_DESCRIPTION = 'Turn SSH into a thin client specifically for your app' SSHCOMMAND_REPO_NAME ?= progrium/sshcommand @@ -26,7 +26,7 @@ GOROOT = /usr/lib/go GOBIN = /usr/bin/go GOPATH = /home/vagrant/gocode -.PHONY: install-from-deb deb-all deb-herokuish deb-dokku deb-gems deb-pluginhook deb-setup deb-sshcommand +.PHONY: install-from-deb deb-all deb-herokuish deb-dokku deb-gems deb-plugn deb-setup deb-sshcommand install-from-deb: echo "--> Initial apt-get update" @@ -54,7 +54,7 @@ install-from-deb: echo "--> Done!" -deb-all: deb-herokuish deb-dokku deb-gems deb-pluginhook deb-sshcommand +deb-all: deb-herokuish deb-dokku deb-gems deb-plugn deb-sshcommand mv /tmp/*.deb . echo "Done" @@ -128,24 +128,24 @@ deb-gems: deb-setup find /tmp/tmp/cache -name '*.gem' | xargs -rn1 fpm -d ruby -d ruby --prefix /var/lib/gems/1.9.1 -s gem -t deb -a $(GEM_ARCHITECTURE) mv *.deb /tmp -deb-pluginhook: deb-setup - rm -rf /tmp/tmp /tmp/build $(PLUGINHOOK_PACKAGE_NAME) +deb-plugn: deb-setup + rm -rf /tmp/tmp /tmp/build $(PLUGN_PACKAGE_NAME) mkdir -p /tmp/tmp /tmp/build echo "-> Cloning repository" - git clone -q "git@github.com:$(PLUGINHOOK_REPO_NAME).git" /tmp/tmp/pluginhook > /dev/null - rm -rf /tmp/tmp/pluginhook/.git /tmp/tmp/pluginhook/.gitignore + git clone -q "git@github.com:$(PLUGN_REPO_NAME).git" /tmp/tmp/plugn > /dev/null + rm -rf /tmp/tmp/plugn/.git /tmp/tmp/plugn/.gitignore echo "-> Copying files into place" mkdir -p /tmp/build/usr/local/bin $(GOPATH) sudo apt-get update > /dev/null sudo apt-get install -qq -y git golang mercurial 2>&1 > /dev/null export PATH=$(PATH):$(GOROOT)/bin:$(GOPATH)/bin && export GOROOT=$(GOROOT) && export GOPATH=$(GOPATH) && go get "golang.org/x/crypto/ssh/terminal" - export PATH=$(PATH):$(GOROOT)/bin:$(GOPATH)/bin && export GOROOT=$(GOROOT) && export GOPATH=$(GOPATH) && cd /tmp/tmp/pluginhook && go build -o pluginhook - mv /tmp/tmp/pluginhook/pluginhook /tmp/build/usr/local/bin/pluginhook + export PATH=$(PATH):$(GOROOT)/bin:$(GOPATH)/bin && export GOROOT=$(GOROOT) && export GOPATH=$(GOPATH) && cd /tmp/tmp/plugn && go build -o plugn + mv /tmp/tmp/plugn/plugn /tmp/build/usr/local/bin/plugn - echo "-> Creating $(PLUGINHOOK_PACKAGE_NAME)" - sudo fpm -t deb -s dir -C /tmp/build -n pluginhook -v $(PLUGINHOOK_VERSION) -a $(PLUGINHOOK_ARCHITECTURE) -p $(PLUGINHOOK_PACKAGE_NAME) --url "https://github.com/$(PLUGINHOOK_REPO_NAME)" --description $(PLUGINHOOK_DESCRIPTION) --license 'MIT License' . + echo "-> Creating $(PLUGN_PACKAGE_NAME)" + sudo fpm -t deb -s dir -C /tmp/build -n plugn -v $(PLUGN_VERSION) -a $(PLUGN_ARCHITECTURE) -p $(PLUGN_PACKAGE_NAME) --url "https://github.com/$(PLUGN_REPO_NAME)" --description $(PLUGN_DESCRIPTION) --license 'MIT License' . mv *.deb /tmp deb-sshcommand: deb-setup diff --git a/debian/control b/debian/control index d4b026362..d297bc846 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Version: 0.3.12 Section: base Priority: optional Architecture: amd64 -Depends: locales, git, make, curl, software-properties-common, lxc-docker-1.6.2, gcc, python-software-properties, man-db, herokuish, sshcommand, pluginhook +Depends: locales, git, make, curl, software-properties-common, lxc-docker-1.6.2, gcc, python-software-properties, man-db, herokuish, sshcommand, plugn Pre-Depends: nginx, dnsutils, ruby, ruby-dev, rubygem-rack, rubygem-rack-protection, rubygem-sinatra, rubygem-tilt, apparmor, cgroupfs-mount | cgroup-lite Maintainer: Jose Diaz-Gonzalez Description: Docker powered mini-Heroku in around 100 lines of Bash diff --git a/debian/postinst b/debian/postinst index d9d94b818..07c27fe4e 100755 --- a/debian/postinst +++ b/debian/postinst @@ -16,7 +16,7 @@ case "$1" in sshcommand create dokku /usr/local/bin/dokku egrep -i "^docker" /etc/group || groupadd docker usermod -aG docker dokku - dokku plugins-install + dokku plugin:install --core rm -f /home/dokku/VERSION cp /var/lib/dokku/STABLE_VERSION /home/dokku/VERSION @@ -31,7 +31,7 @@ case "$1" in db_get "dokku/vhost_enable" if [ "$RET" = "true" ]; then - db_get "dokku/hostname" + db_get "dokku/hostname" echo "$RET" > "${DOKKU_ROOT}/VHOST" else rm -f "${DOKKU_ROOT}/VHOST" diff --git a/docs/advanced-installation.md b/docs/advanced-installation.md index bab3666b9..eed676675 100644 --- a/docs/advanced-installation.md +++ b/docs/advanced-installation.md @@ -16,7 +16,7 @@ cd dokku sudo make install ``` -The `Makefile` allows source URLs to be overridden to include customizations from your own repositories. The `DOCKER_URL`, `PLUGINHOOK_URL`, `SSHCOMMAND_URL` and `STACK_URL` environment variables may be set to override the defaults (see the `Makefile` for how these apply). Example: +The `Makefile` allows source URLs to be overridden to include customizations from your own repositories. The `DOCKER_URL`, `PLUGN_URL`, `SSHCOMMAND_URL` and `STACK_URL` environment variables may be set to override the defaults (see the `Makefile` for how these apply). Example: ```shell sudo SSHCOMMAND_URL=https://raw.github.com/yourusername/sshcommand/master/sshcommand make install diff --git a/docs/components.md b/docs/components.md index a6bfa453f..fc43b9a91 100644 --- a/docs/components.md +++ b/docs/components.md @@ -2,7 +2,7 @@ * [Docker](https://github.com/dotcloud/docker) - Container runtime and manager * [Herokuish](https://github.com/gliderlabs/herokuish) - Buildpack builder - * [pluginhook](https://github.com/progrium/pluginhook) - Shell based plugins and hooks + * [plugn](https://github.com/progrium/plugn) - Shell based plugins and hooks * [sshcommand](https://github.com/progrium/sshcommand) - Fixed commands over SSH Looking to keep codebase as simple and hackable as possible, so try to keep your line count down. diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 13ee06120..7c5c1a9cf 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -3,7 +3,7 @@ If you create your own plugin: 1. Take a look at the plugins shipped with dokku and hack away! -2. Check out the [list of hooks](http://progrium.viewdocs.io/dokku/development/pluginhooks) your plugin can implement. +2. Check out the [list of triggers](http://progrium.viewdocs.io/dokku/development/plugin-triggers) your plugin can implement. 3. Upload your plugin to github with a repository name in form of `dokku-` (e.g. `dokku-mariadb`) 4. Edit [this page](http://progrium.viewdocs.io/dokku/plugins) and add a link to it. 5. Subscribe to the [dokku development blog](http://progrium.com) to be notified about API changes and releases @@ -15,7 +15,7 @@ The below plugin is a dummy `dokku hello` plugin. If your plugin exposes command ```shell #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" case "$1" in hello) @@ -31,7 +31,7 @@ case "$1" in ;; help) - cat && cat<, Says "Hello " hello:world, Says "Hello world" EOF @@ -44,6 +44,15 @@ EOF esac ``` +Each plugin requires a `plugin.toml` descriptor file with the following required fields: + +```shell +[plugin] +description = "dokku hello plugin" +version = "0.1.0" +[plugin.config] +``` + A few notes: - You should always support `DOKKU_TRACE` as specified on the 2nd line of the plugin. @@ -56,7 +65,7 @@ A few notes: ```shell IMAGE=$(docker images | grep "user/repo" | awk '{print $3}') if [[ -z $IMAGE ]]; then - dokku_log_fail "user/repo image not found... Did you run 'dokku plugins-install'?" + dokku_log_fail "user/repo image not found... Did you run 'dokku plugin:install'?" fi ``` @@ -79,5 +88,5 @@ A few notes: dokku config:set --no-restart APP KEY1=VALUE1 [KEY2=VALUE2 ...] dokku config:unset --no-restart APP KEY1 [KEY2 ...] ``` -- From time to time you may want to allow other plugins access to (some of) your plugin's functionality. You can expose this by including a `functions` file in your plugin for others to source. Consider all functions in that file to be publicly accessible by other plugins. Any functions not wished to be made "public" should reside within your pluginhook or commands files. -- As of 0.4.0, we allow image tagging and deployment of said tagged images. Therefore, hard-coding of `$IMAGE` as `dokku/$APP` is no longer sufficient. Instead, for non `pre/post-build-*` plugins, use `get_running_image_tag()` & `get_app_image_name()` as sourced from common/functions. See [pluginhooks](http://progrium.viewdocs.io/dokku/development/pluginhooks) doc for examples. +- From time to time you may want to allow other plugins access to (some of) your plugin's functionality. You can expose this by including a `functions` file in your plugin for others to source. Consider all functions in that file to be publicly accessible by other plugins. Any functions not wished to be made "public" should reside within your plugin trigger or commands files. +- As of 0.4.0, we allow image tagging and deployment of said tagged images. Therefore, hard-coding of `$IMAGE` as `dokku/$APP` is no longer sufficient. Instead, for non `pre/post-build-*` plugins, use `get_running_image_tag()` & `get_app_image_name()` as sourced from common/functions. See the [plugin triggers](http://progrium.viewdocs.io/dokku/development/plugin-triggers) doc for examples. diff --git a/docs/development/pluginhooks.md b/docs/development/plugin-triggers.md similarity index 86% rename from docs/development/pluginhooks.md rename to docs/development/plugin-triggers.md index 63287f670..50e7fdb35 100644 --- a/docs/development/pluginhooks.md +++ b/docs/development/plugin-triggers.md @@ -1,15 +1,15 @@ -# Pluginhooks +# Plugin triggers -[Pluginhooks](https://github.com/progrium/pluginhook) are a good way to jack into existing dokku infrastructure. You can use them to modify the output of various dokku commands or override internal configuration. +[Plugin triggers](https://github.com/progrium/plugn) (formerly [pluginhooks](https://github.com/progrium/pluginhook)) are a good way to jack into existing dokku infrastructure. You can use them to modify the output of various dokku commands or override internal configuration. -Pluginhooks are simply scripts that are executed by the system. You can use any language you want, so long as the script: +Plugin triggers are simply scripts that are executed by the system. You can use any language you want, so long as the script: - Is executable - Has the proper language requirements installed -For instance, if you wanted to write a pluginhook in PHP, you would need to have `php` installed and available on the CLI prior to pluginhook invocation. +For instance, if you wanted to write a plugin trigger in PHP, you would need to have `php` installed and available on the CLI prior to plugin trigger invocation. -The following is an example for the `nginx-hostname` pluginhook. It reverses the hostname that is provided to nginx during deploys. If you created an executable file named `nginx-hostname` with the following code in your plugin, it would be invoked by dokku during the normal app deployment process: +The following is an example for the `nginx-hostname` plugin trigger. It reverses the hostname that is provided to nginx during deploys. If you created an executable file named `nginx-hostname` with the following code in your plugin trigger, it would be invoked by dokku during the normal app deployment process: ```shell #!/usr/bin/env bash @@ -21,18 +21,18 @@ NEW_SUBDOMAIN=`echo $SUBDOMAIN | rev` echo "$NEW_SUBDOMAIN.$VHOST" ``` -## Available Pluginhooks +## Available plugin triggers -There are a number of plugin-related pluginhooks. These can be optionally implemented by plugins and allow integration into the standard dokku plugin setup/backup/teardown process. +There are a number of plugin-related triggers. These can be optionally implemented by plugins and allow integration into the standard dokku setup/backup/teardown process. -The following pluginhooks describe those available to a dokku installation. As well, there is an example for each pluginhook that you can use as templates for your own plugin development. +The following plugin triggers describe those available to a dokku installation. As well, there is an example for each trigger that you can use as templates for your own plugin development. -> The example pluginhook code is not guaranteed to be implemented as in within dokkku, and are merely simplified examples. Please look at the dokku source for larger, more in-depth examples. +> The example plugin trigger code is not guaranteed to be implemented as in within dokkku, and are merely simplified examples. Please look at the dokku source for larger, more in-depth examples. ### `install` - Description: Used to setup any files/configuration for a plugin. -- Invoked by: `dokku plugins-install`. +- Invoked by: `dokku plugin:install`. - Arguments: None - Example: @@ -50,8 +50,8 @@ fi ### `dependencies` -- Description: Used to install system-level dependencies. Invoked by `plugins-install-dependencies`. -- Invoked by: `dokku plugins-install-dependencies` +- Description: Used to install system-level dependencies. Invoked by `plugin:install-dependencies`. +- Invoked by: `dokku plugin:install-dependencies` - Arguments: None - Example: @@ -77,7 +77,7 @@ esac ### `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. -- Invoked by: `dokku plugins-update`. +- Invoked by: `dokku plugin:update`. - Arguments: None - Example: @@ -93,7 +93,7 @@ sudo BUILD_STACK=true make install ### `commands help` -- Description: Used to aggregate all plugin `help` output. Your plugin should implement a `help` command in your `commands` file to take advantage of this pluginhook. This must be implemented inside the `commands` pluginhook file. +- Description: Used to aggregate all plugin `help` output. Your plugin should implement a `help` command in your `commands` file to take advantage of this plugin trigger. This must be implemented inside the `commands` plugin file. - Invoked by: `dokku help` - Arguments: None - Example: @@ -106,7 +106,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x case "$1" in help | derp:help) - cat && cat< /dev/null # Installs a package specified by the `CONTAINER_PACKAGE` env var set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -305,7 +305,7 @@ docker commit $ID $IMAGE > /dev/null #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -323,7 +323,7 @@ verify_app_name "$APP" #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -343,7 +343,7 @@ verify_app_name "$APP" # `DOKKU_DISABLE_DEPLOY` env var is set to `true` for an app set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/config/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" CONTAINERID="$1"; APP="$2"; PORT="$3" ; HOSTNAME="${4:-localhost}" @@ -368,7 +368,7 @@ fi # Runs gulp in our container set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -407,7 +407,7 @@ curl "http://httpstat.us/200" # Clears out the gulp asset build cache for applications set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1"; GULP_CACHE_DIR="$DOKKU_ROOT/$APP/gulp"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -462,7 +462,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -480,7 +480,7 @@ verify_app_name "$APP" #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" @@ -626,7 +626,7 @@ if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then REFERENCE_REPO="$DOKKU_ROOT/$reference_app git clone --bare --shared --reference "$REFERENCE_REPO" "$REFERENCE_REPO" "$DOKKU_ROOT/$APP" > /dev/null fi -pluginhook receive-app $APP $newrev +plugn trigger receive-app $APP $newrev ``` ### `tags-create` diff --git a/docs/dokku-events-logs.md b/docs/dokku-events-logs.md index 8ff961adb..462855d53 100644 --- a/docs/dokku-events-logs.md +++ b/docs/dokku-events-logs.md @@ -21,10 +21,10 @@ Enabling dokku events logger Dokku will then write log entries to ``/var/log/syslog`` as well as a Dokku-specific logs sub-directory ``/var/log/dokku/events.log``, which can be easily displayed with the command `dokku events`: ``` -Jul 3 16:09:48 dokku.me dokku[127630]: INVOKED: pre-release-buildstep( pythonapp ) +Jul 3 16:09:48 dokku.me dokku[127630]: INVOKED: pre-release-buildpack( pythonapp ) Jul 3 16:10:02 dokku.me dokku[128095]: INVOKED: docker-args-run( rubyapp ) Jul 3 16:10:02 dokku.me dokku[128114]: INVOKED: docker-args-run( nhl ) -Jul 3 16:10:03 dokku.me dokku[128136]: INVOKED: post-release-buildstep( pythonapp ) +Jul 3 16:10:03 dokku.me dokku[128136]: INVOKED: post-release-buildpack( pythonapp ) Jul 3 16:10:03 dokku.me dokku[128195]: INVOKED: pre-deploy( pythonapp ) Jul 3 16:10:23 dokku.me dokku[129253]: INVOKED: docker-args-deploy( pythonapp ) Jul 3 16:10:24 dokku.me dokku[129337]: INVOKED: bind-external-ip( pythonapp ) @@ -47,10 +47,10 @@ docker-args-build pre-delete post-deploy receive-app -pre-release-buildstep +pre-release-buildpack nginx-pre-reload docker-args-deploy -post-build-buildstep +post-build-buildpack post-domains-update post-release-dockerfile check-deploy @@ -63,10 +63,10 @@ bind-external-ip pre-deploy post-delete dependencies -pre-build-buildstep +pre-build-buildpack docker-args-run pre-build-dockerfile -post-release-buildstep +post-release-buildpack post-build-dockerfile pre-release-dockerfile update diff --git a/docs/nginx.md b/docs/nginx.md index 944514bc2..2bbbbe92e 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -126,7 +126,7 @@ scheme://subdomain.domain.tld The `subdomain` is inferred from the pushed application name, while the `domain` is set during initial configuration in the `$DOKKU_ROOT/VHOST` file. -You can optionally override this in a plugin by implementing the `nginx-hostname` pluginhook. For example, you can reverse the subdomain with the following sample `nginx-hostname` pluginhook: +You can optionally override this in a plugin by implementing the `nginx-hostname` plugin trigger. For example, you can reverse the subdomain with the following sample `nginx-hostname` plugin trigger: ```shell #!/usr/bin/env bash diff --git a/docs/plugins.md b/docs/plugins.md index d7e6819f6..b1f71dba5 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -1,10 +1,11 @@ # Plugins -Dokku itself is built out of plugins and uses [pluginhook](https://github.com/progrium/pluginhook) for its plugin system. In essence a plugin is a collection of scripts that will be run based on naming convention. +Dokku itself is built out of plugins and uses [plugn](https://github.com/progrium/plugn) for its plugin system. In essence a plugin is a collection of scripts that will be run based on naming convention. Let's take a quick look at the current dokku nginx plugin that's shipped with dokku by default. nginx-vhosts/ + ├── plugin.toml # plugin metadata ├── commands # contains additional commands ├── install # runs on dokku installation └── post-deploy # runs after an app is deployed @@ -12,9 +13,9 @@ Let's take a quick look at the current dokku nginx plugin that's shipped with do ## Installing a plugin ```shell -cd /var/lib/dokku/plugins +cd /var/lib/dokku/plugins/available git clone -dokku plugins-install +dokku plugin:install ``` ## Creating your own plugin diff --git a/docs/process-management.md b/docs/process-management.md index f7c5e6b4c..bf28f79e1 100644 --- a/docs/process-management.md +++ b/docs/process-management.md @@ -13,9 +13,6 @@ ps:start Start app container(s) ps:stop Stop app container(s) ``` -*NOTE*: As of v0.3.14, `dokku deploy:all` in now deprecated by `ps:restartall` and will be removed in a future version. - - ## Scaling Dokku allows you to run multiple process types at different container counts. For example, if you had an app that contained 1 web app listener and 1 background job processor, dokku can, spin up 1 container for each process type defined in the Procfile. By default we will only start the web process. However, if you wanted 2 job processors running simultaneously, you can modify this behavior in a few ways. diff --git a/docs/template.html b/docs/template.html index fa646570e..ec20cf893 100644 --- a/docs/template.html +++ b/docs/template.html @@ -77,7 +77,7 @@ Development Plugin Creation - Pluginhooks + Plugin Triggers Test Suite Release Process diff --git a/dokku b/dokku index 9625e5905..3dd1f314c 100755 --- a/dokku +++ b/dokku @@ -5,15 +5,23 @@ shopt -s nullglob export DOKKU_DISTRO=${DOKKU_DISTRO:="ubuntu"} export DOKKU_IMAGE=${DOKKU_IMAGE:="gliderlabs/herokuish"} export DOKKU_ROOT=${DOKKU_ROOT:=~dokku} +export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"} -export PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"} +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_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 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/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 @@ -33,7 +41,7 @@ if [[ "${args[0]}" =~ ^--.* ]]; then fi ! has_tty && DOKKU_QUIET_OUTPUT=1 -if [[ $(id -un) != "dokku" && $1 != plugins-install* && $1 != "plugins-update" ]]; then +if [[ $(id -un) != "dokku" && $1 != plugin:*install* && $1 != "plugin:update" ]]; then sudo -u dokku -E -H $0 "$@" exit fi @@ -63,7 +71,7 @@ case "$1" in [[ -z $2 ]] && dokku_log_fail "Please specify an app to deploy" APP="$2"; IMAGE_TAG="$3"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) verify_app_name "$APP" - pluginhook pre-deploy $APP $IMAGE_TAG + plugn trigger pre-deploy $APP $IMAGE_TAG is_image_herokuish_based "$IMAGE" && DOKKU_HEROKUISH=true DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE" @@ -82,11 +90,10 @@ case "$1" in DOKKU_PORT_FILE="$DOKKU_ROOT/$APP/PORT.$PROC_TYPE.$CONTAINER_INDEX" # start the app - DOCKER_ARGS=$(: | pluginhook docker-args $APP deploy $IMAGE_TAG) - DOCKER_ARGS+=" -e DYNO='$PROC_TYPE.$CONTAINER_INDEX' " - DOCKER_ARGS+=$(: | pluginhook docker-args-deploy $APP $IMAGE_TAG) + DOCKER_ARGS=" -e DYNO='$PROC_TYPE.$CONTAINER_INDEX' " + DOCKER_ARGS+=$(: | plugn trigger docker-args-deploy $APP $IMAGE_TAG) [[ "$DOKKU_TRACE" ]] && DOCKER_ARGS+=" -e TRACE=true " - BIND_EXTERNAL=$(pluginhook bind-external-ip $APP) + BIND_EXTERNAL=$(plugn trigger bind-external-ip $APP) [[ -n "$DOKKU_HEROKUISH" ]] && START_CMD="/start $PROC_TYPE" @@ -130,7 +137,7 @@ case "$1" in else trap kill_new INT TERM EXIT dokku_log_info1 "Running pre-flight checks" - pluginhook check-deploy $APP $id $PROC_TYPE $port $ipaddr + plugn trigger check-deploy $APP $id $PROC_TYPE $port $ipaddr trap - INT TERM EXIT fi @@ -158,7 +165,7 @@ case "$1" in done < "$DOKKU_SCALE_FILE" dokku_log_info1 "Running post-deploy" - pluginhook post-deploy $APP $port $ipaddr + plugn trigger post-deploy $APP $port $ipaddr # kill the old container if [[ -n "$oldids" ]]; then @@ -185,7 +192,7 @@ case "$1" in # on to the next. docker stop $oldid \ || docker kill $oldid \ - || pluginhook retire-container-failed $APP # Trigger pluginhook for event logging + || plugn trigger retire-container-failed $APP # plugin trigger for event logging done ) & disown -a # Use trap since disown/nohup don't seem to keep child alive @@ -198,22 +205,6 @@ case "$1" in docker_cleanup ;; - plugins) - ls -1 -d $PLUGIN_PATH/*/ - ;; - - plugins-install) - pluginhook install - ;; - - plugins-install-dependencies) - pluginhook dependencies - ;; - - plugins-update) - pluginhook update - ;; - # DEPRECATED as of v0.3.14 deploy:all) echo "*DEPRECATED* in v0.3.14: deploy:all will be removed in future versions" @@ -225,17 +216,14 @@ case "$1" in echo "" echo "Options:" - cat< /dev/null [[ -d $CACHE_DIR ]] || mkdir $CACHE_DIR - # *DEPRECATED* in v0.3.15: `pluginhook pre-build` will be removed in future releases - pluginhook pre-build "$APP" - # *DEPRECATED* in v0.3.22: `pluginhook pre-build-buildstep` will be removed in future releases - pluginhook pre-build-buildstep "$APP" - pluginhook pre-build-buildpack "$APP" + plugn trigger pre-build-buildpack "$APP" - # *DEPRECATED* in v0.3.14: `pluginhook docker-args` will be removed in future releases - # https://github.com/progrium/dokku/issues/896 & https://github.com/progrium/dokku/issues/906 - DOCKER_ARGS=$(: | pluginhook docker-args $APP build) - DOCKER_ARGS+=$(: | pluginhook docker-args-build $APP) + DOCKER_ARGS=$(: | plugn trigger docker-args-build $APP) [[ "$DOKKU_TRACE" ]] && DOCKER_ARGS+=" -e TRACE=true " id=$(docker run -d -v $CACHE_DIR:/cache -e CACHE_PATH=/cache $DOCKER_ARGS $IMAGE /build) docker attach $id test "$(docker wait $id)" -eq 0 docker commit $id $IMAGE > /dev/null - # *DEPRECATED* in v0.3.15: `pluginhook post-build` will be removed in future releases - pluginhook post-build "$APP" - # *DEPRECATED* in v0.3.22: `pluginhook post-build-buildstep` will be removed in future releases - pluginhook post-build-buildstep "$APP" - pluginhook post-build-buildpack "$APP" + plugn trigger post-build-buildpack "$APP" ;; dockerfile) # extract first port from Dockerfile DOCKERFILE_PORT=$(get_dockerfile_exposed_port Dockerfile) [[ -n "$DOCKERFILE_PORT" ]] && config_set --no-restart $APP DOKKU_DOCKERFILE_PORT=$DOCKERFILE_PORT - pluginhook pre-build-dockerfile "$APP" + plugn trigger pre-build-dockerfile "$APP" [[ "$DOKKU_DOCKERFILE_CACHE_BUILD" == "false" ]] && DOKKU_DOCKER_BUILD_OPTS="$DOKKU_DOCKER_BUILD_OPTS --no-cache" docker build $DOKKU_DOCKER_BUILD_OPTS -t "$IMAGE" . - pluginhook post-build-dockerfile "$APP" + plugn trigger post-build-dockerfile "$APP" ;; *) @@ -66,11 +55,7 @@ case "$1" in case "$IMAGE_SOURCE_TYPE" in herokuish) - # *DEPRECATED* in v0.3.15: `pluginhook pre-release` will be removed in future releases - pluginhook pre-release $APP $IMAGE_TAG - # *DEPRECATED* in v0.3.22: `pluginhook pre-release-buildstep` will be removed in future releases - pluginhook pre-release-buildstep $APP $IMAGE_TAG - pluginhook pre-release-buildpack $APP $IMAGE_TAG + plugn trigger pre-release-buildpack "$APP" "$IMAGE_TAG" if [[ -n $(config_export global) ]]; then id=$(config_export global | docker run -i -a stdin $IMAGE /bin/bash -c "mkdir -p /app/.profile.d && cat > /app/.profile.d/00-global-env.sh") test "$(docker wait $id)" -eq 0 @@ -81,16 +66,13 @@ case "$1" in test "$(docker wait $id)" -eq 0 docker commit $id $IMAGE > /dev/null fi - # *DEPRECATED* in v0.3.15: `pluginhook post-release` will be removed in future releases - pluginhook post-release $APP $IMAGE_TAG - # *DEPRECATED* in v0.3.22: `pluginhook post-release-buildstep` will be removed in future releases - pluginhook post-release-buildstep $APP $IMAGE_TAG - pluginhook post-release-buildpack $APP $IMAGE_TAG + plugn trigger post-release-buildpack "$APP" "$IMAGE_TAG" ;; dockerfile) - pluginhook pre-release-dockerfile $APP $IMAGE_TAG - pluginhook post-release-dockerfile $APP $IMAGE_TAG + # buildstep plugins don't necessarily make sense for dockerfiles. call the new breed!!! + plugn trigger pre-release-dockerfile "$APP" "$IMAGE_TAG" + plugn trigger post-release-dockerfile "$APP" "$IMAGE_TAG" ;; *) @@ -175,8 +157,7 @@ case "$1" in shift 2 - DOCKER_ARGS=$(: | pluginhook docker-args $APP run $IMAGE_TAG) - DOCKER_ARGS+=$(: | pluginhook docker-args-run $APP $IMAGE_TAG) + DOCKER_ARGS=$(: | plugn trigger docker-args-run $APP $IMAGE_TAG) [[ "$DOKKU_TRACE" ]] && DOCKER_ARGS+=" -e TRACE=true " [[ $DOKKU_RM_CONTAINER ]] && DOKKU_RUN_OPTS="--rm" has_tty && DOKKU_RUN_OPTS+=" -i -t" @@ -222,7 +203,7 @@ case "$1" in ;; help) - cat && cat< [-t], Show the last logs for an application (-t follows) run , Run a command in the environment of an application diff --git a/plugins/00_dokku-standard/plugin.toml b/plugins/00_dokku-standard/plugin.toml new file mode 100644 index 000000000..a11d89221 --- /dev/null +++ b/plugins/00_dokku-standard/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core standard plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/20_events/commands b/plugins/20_events/commands index c3b817735..7d9d502d6 100755 --- a/plugins/20_events/commands +++ b/plugins/20_events/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" PLUGIN_DIR="$(dirname $0)" diff --git a/plugins/20_events/hook b/plugins/20_events/hook index 5357e931b..e9a05dd21 100755 --- a/plugins/20_events/hook +++ b/plugins/20_events/hook @@ -1,5 +1,5 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -[[ ! "$DOKKU_EVENTS" ]] || dokku_log_pluginhook_call "$(basename $0)" "$@" +[[ ! "$DOKKU_EVENTS" ]] || dokku_log_plugn_trigger_call "$(basename $0)" "$@" diff --git a/plugins/20_events/install b/plugins/20_events/install index 8951bd4d1..deed941d4 100755 --- a/plugins/20_events/install +++ b/plugins/20_events/install @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/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 @@ -49,6 +49,6 @@ if [[ "$flag_rsyslog_needs_restart" == "y" ]]; then service rsyslog restart fi -[[ ! "$DOKKU_EVENTS" ]] || dokku_log_pluginhook_call "$(basename $0)" "$@" +[[ ! "$DOKKU_EVENTS" ]] || dokku_log_plugn_trigger_call "$(basename $0)" "$@" exit 0 diff --git a/plugins/20_events/plugin.toml b/plugins/20_events/plugin.toml new file mode 100644 index 000000000..0379b2986 --- /dev/null +++ b/plugins/20_events/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core events logging plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/WARNING b/plugins/WARNING deleted file mode 100644 index d3eee9aac..000000000 --- a/plugins/WARNING +++ /dev/null @@ -1,2 +0,0 @@ - -Please note that the hooks in Dokku are experimental and are likely to change quite a bit. \ No newline at end of file diff --git a/plugins/apps/commands b/plugins/apps/commands index 47a1b304f..9c79b2e55 100755 --- a/plugins/apps/commands +++ b/plugins/apps/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" case "$1" in apps) @@ -38,7 +38,7 @@ case "$1" in echo "Destroying $APP (including all add-ons)" - pluginhook pre-delete $APP $IMAGE_TAG + plugn trigger pre-delete $APP $IMAGE_TAG DOKKU_APP_CIDS=$(get_app_container_ids $APP) if [[ -n $DOKKU_APP_CIDS ]]; then for ID in $DOKKU_APP_CIDS;do @@ -47,11 +47,11 @@ case "$1" in done fi - pluginhook post-delete $APP $IMAGE_TAG + plugn trigger post-delete $APP $IMAGE_TAG ;; help | apps:help) - cat && cat<, Create a new app apps:destroy , Permanently destroy an app diff --git a/plugins/apps/plugin.toml b/plugins/apps/plugin.toml new file mode 100644 index 000000000..8996403e0 --- /dev/null +++ b/plugins/apps/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core apps plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/apps/post-delete b/plugins/apps/post-delete index 5c71e01a2..91fe06e20 100755 --- a/plugins/apps/post-delete +++ b/plugins/apps/post-delete @@ -1,9 +1,9 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" -APP="$1"; IMAGE_REPO=$(get_app_image_repo $APP) +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -[[ -n $APP ]] && rm -r "$DOKKU_ROOT/$APP" > /dev/null +APP="$1"; IMAGE_REPO=$(get_app_image_repo $APP) +[[ -n $APP ]] && rm -rf "$DOKKU_ROOT/$APP" > /dev/null # remove all application containers & images # shellcheck disable=SC2046 diff --git a/plugins/apps/pre-delete b/plugins/apps/pre-delete index a8eb8facb..376baa94b 100755 --- a/plugins/apps/pre-delete +++ b/plugins/apps/pre-delete @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/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" diff --git a/plugins/backup/commands b/plugins/backup/commands index 1d1cf0655..2fa160979 100755 --- a/plugins/backup/commands +++ b/plugins/backup/commands @@ -11,7 +11,7 @@ case "$1" in BACKUP_TMP_DIR=$(mktemp -d) BACKUP_TMP_FILE="$BACKUP_TMP_DIR/backup.tar" - : | pluginhook backup-export 1 $BACKUP_DIR | tar -cf $BACKUP_TMP_FILE --files-from - + : | plugn trigger backup-export 1 $BACKUP_DIR | tar -cf $BACKUP_TMP_FILE --files-from - pushd $BACKUP_DIR > /dev/null find . -maxdepth 1 -type d -not -name . | sed 's:./::g' > "$BACKUP_TMP_DIR/.dokku_backup_apps" @@ -63,7 +63,7 @@ case "$1" in BACKUP_ROOT="$BACKUP_TMP_DIR""$DOKKU_ROOT" TARGET_DIR="$DOKKU_ROOT" - if ! pluginhook backup-check $VERSION "$BACKUP_ROOT" "$TARGET_DIR" "$BACKUP_TMP_DIR/.dokku_backup_apps"; then + if ! plugn trigger backup-check $VERSION "$BACKUP_ROOT" "$TARGET_DIR" "$BACKUP_TMP_DIR/.dokku_backup_apps"; then if $force; then echo "-f used. Ignoring warnings." else @@ -75,7 +75,7 @@ case "$1" in while read app; do mkdir "$TARGET_DIR/$app"; echo "Imported $app"; done < $BACKUP_TMP_DIR/.dokku_backup_apps # have the plugins import their stuff - pluginhook backup-import $VERSION "$BACKUP_ROOT" $TARGET_DIR "$BACKUP_TMP_DIR/.dokku_backup_apps" + plugn trigger backup-import $VERSION "$BACKUP_ROOT" $TARGET_DIR "$BACKUP_TMP_DIR/.dokku_backup_apps" rm -rf $BACKUP_TMP_DIR @@ -83,7 +83,7 @@ case "$1" in ;; help | backup:help) - cat && cat<> "$DOKKU_ROOT/ENV" && { - dokku_log_info2 "Using a global BUILD_ENV file is deprecated as of 0.3.26" - rm "$DOKKU_ROOT/BUILD_ENV" -} - config_get --global CURL_CONNECT_TIMEOUT > /dev/null 2>&1 || config_set --global CURL_CONNECT_TIMEOUT=5 config_get --global CURL_TIMEOUT > /dev/null 2>&1 || config_set --global CURL_TIMEOUT=30 diff --git a/plugins/certs/commands b/plugins/certs/commands index a46e9865b..ba6e62bc0 100755 --- a/plugins/certs/commands +++ b/plugins/certs/commands @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" -source "$(dirname $0)/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/certs/functions" is_tar_import() { [[ -t 0 ]] && return 1 @@ -144,7 +144,7 @@ case "$1" in if [[ -d "$APP_SSL_PATH" ]]; then dokku_log_info1 "Removing SSL endpoint from $APP" rm -rf $APP_SSL_PATH - pluginhook post-domains-update $APP + plugn trigger post-domains-update $APP else dokku_log_info1 "An app-specific SSL endpoint is not defined" fi diff --git a/plugins/certs/functions b/plugins/certs/functions index e125c72ed..1e852846b 100755 --- a/plugins/certs/functions +++ b/plugins/certs/functions @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" # returns 'global', 'app', 'false' # if both are configured, app trumps global diff --git a/plugins/certs/plugin.toml b/plugins/certs/plugin.toml new file mode 100644 index 000000000..f69100fa6 --- /dev/null +++ b/plugins/certs/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core certificate management plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/checks/check-deploy b/plugins/checks/check-deploy index 85ac68dce..4ff53ad50 100755 --- a/plugins/checks/check-deploy +++ b/plugins/checks/check-deploy @@ -35,8 +35,8 @@ # set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" -source "$PLUGIN_PATH/config/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_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 diff --git a/plugins/checks/plugin.toml b/plugins/checks/plugin.toml new file mode 100644 index 000000000..b03b5b7ba --- /dev/null +++ b/plugins/checks/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core checks plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/common/functions b/plugins/common/functions index 1a12eeb6b..8e1dcccb2 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -94,7 +94,7 @@ dokku_log_event() { logger -t dokku -i -- "$@" } -dokku_log_pluginhook_call() { +dokku_log_plugn_trigger_call() { local l_hook l_hook="$1" ; shift @@ -325,6 +325,7 @@ docker_cleanup() { # delete all non-running containers # shellcheck disable=SC2046 docker rm $(docker ps -a -f 'status=exited' -q) &> /dev/null || true + # delete unused images # shellcheck disable=SC2046 docker rmi $(docker images -f 'dangling=true' -q) &> /dev/null & diff --git a/plugins/common/plugin.toml b/plugins/common/plugin.toml new file mode 100644 index 000000000..6f55ffa71 --- /dev/null +++ b/plugins/common/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core common plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/config/commands b/plugins/config/commands index 5042ad245..191af9f52 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" -source "$PLUGIN_PATH/config/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" case "$1" in config) @@ -20,20 +20,8 @@ case "$1" in config_unset "$@" ;; - config:set-norestart) - dokku_log_info2 "$1 is deprecated as of v0.3.22" - shift 1 - dokku config:set --no-restart "$@" - ;; - - config:unset-norestart) - dokku_log_info2 "$1 is deprecated as of v0.3.22" - shift 1 - dokku config:unset --no-restart "$@" - ;; - help | config:help) - cat && cat<|--global), Display all global or app-specific config vars config:get (|--global) KEY, Display a global or app-specific config value config:set (|--global) KEY1=VALUE1 [KEY2=VALUE2 ...], Set one or more config vars diff --git a/plugins/config/docker-args-deploy b/plugins/config/docker-args-deploy index f63a2cb5b..51d80f193 100755 --- a/plugins/config/docker-args-deploy +++ b/plugins/config/docker-args-deploy @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" -source "$PLUGIN_PATH/config/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_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" diff --git a/plugins/config/functions b/plugins/config/functions index a07d23fbc..51debd179 100644 --- a/plugins/config/functions +++ b/plugins/config/functions @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" config_export() { local CONFIG_TYPE="$1" diff --git a/plugins/config/plugin.toml b/plugins/config/plugin.toml new file mode 100644 index 000000000..21b3aa661 --- /dev/null +++ b/plugins/config/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core config plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index 3834660a9..e2e434de7 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" PHASES=(build deploy run) @@ -140,7 +140,7 @@ case "$1" in # Display usage help help) - cat && cat<, Display apps docker options for all phases docker-options , Display apps docker options for phase (comma separated phase list) docker-options:add OPTION, Add docker option to app for phase (comma separated phase list) diff --git a/plugins/docker-options/plugin.toml b/plugins/docker-options/plugin.toml new file mode 100644 index 000000000..b986665b1 --- /dev/null +++ b/plugins/docker-options/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core docker-options plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/domains/commands b/plugins/domains/commands index 9f4f78a11..553862634 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" -source "$PLUGIN_PATH/config/functions" -source "$PLUGIN_PATH/domains/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" +source "$PLUGIN_AVAILABLE_PATH/domains/functions" RE_IPV4="([0-9]{1,3}[\.]){3}[0-9]{1,3}" @@ -57,7 +57,7 @@ case "$1" in if [[ -f "$DOKKU_ROOT/VHOST" ]]; then dokku_log_info1 "Creating new $VHOST_PATH..." SUBDOMAIN=${APP/%\.${VHOST}/} - hostname=$(: | pluginhook nginx-hostname $APP $SUBDOMAIN $VHOST) + hostname=$(: | plugn trigger nginx-hostname $APP $SUBDOMAIN $VHOST) if [[ ! -n $hostname ]]; then if [[ "$APP" == *.* ]] && [[ "$SUBDOMAIN" == "$APP" ]]; then hostname="${APP/\//-}" @@ -95,7 +95,7 @@ case "$1" in done # we need to restart the app to make sure we're binding to the appropriate network interface dokku nginx:build-config $APP - pluginhook post-domains-update $APP + plugn trigger post-domains-update $APP for DOMAIN in "$@";do dokku_log_info1 "Added $DOMAIN to $APP" done @@ -109,7 +109,7 @@ case "$1" in rm -f "$DOKKU_ROOT/$APP/VHOST" dokku domains:setup $APP - pluginhook post-domains-update $APP + plugn trigger post-domains-update $APP dokku_log_info1 "Cleared domains in $APP" ;; @@ -130,7 +130,7 @@ case "$1" in for DOMAIN in "$@";do sed -i "/^$DOMAIN$/d" "$DOKKU_ROOT/$APP/VHOST" done - pluginhook post-domains-update $APP + plugn trigger post-domains-update $APP for DOMAIN in "$@";do dokku_log_info1 "Removed $DOMAIN from $APP" done @@ -138,7 +138,7 @@ case "$1" in ;; help | domains:help) - cat && cat<, List custom domains for app domains:add DOMAIN, Add a custom domain to app domains:clear , Clear all custom domains for app diff --git a/plugins/domains/functions b/plugins/domains/functions index f79e889ee..2a69c42a0 100755 --- a/plugins/domains/functions +++ b/plugins/domains/functions @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname $0)/../common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" get_app_domains() { local APP=$1; verify_app_name $APP diff --git a/plugins/domains/plugin.toml b/plugins/domains/plugin.toml new file mode 100644 index 000000000..61195367e --- /dev/null +++ b/plugins/domains/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core domains plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/enter/commands b/plugins/enter/commands index dd5a592ef..b8e0bdbdc 100755 --- a/plugins/enter/commands +++ b/plugins/enter/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" case "$1" in enter) diff --git a/plugins/enter/plugin.toml b/plugins/enter/plugin.toml new file mode 100644 index 000000000..3e42aeea1 --- /dev/null +++ b/plugins/enter/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core enter plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/git/commands b/plugins/git/commands index 4848db0f3..910df652d 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" git_build_app_repo() { verify_app_name "$1" @@ -36,11 +36,11 @@ case "$1" in # Only run this script for the master branch. You can remove this # if block if you wish to run it for others as well. if [[ $refname = "refs/heads/master" ]] ; then - # broken out into pluginhook so we might support other methods to receive an app - pluginhook -p receive-app $APP $newrev + # broken out into plugin so we might support other methods to receive an app + plugn trigger receive-app $APP $newrev else if test -f "$PLUGIN_PATH"/enabled/*/receive-branch; then - pluginhook receive-branch $APP $newrev $refname + plugn trigger receive-branch $APP $newrev $refname else echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to master." echo $'\e[1G\e[K'"-----> for example, try 'git push ${refname/refs\/heads\/}:master'" @@ -51,9 +51,9 @@ case "$1" in git-upload-pack) APP="$(echo $2 | perl -pe 's/(? Configuring {}..." <<< "$NONSSL_VHOSTS" - [[ -z "$NGINX_CUSTOM_TEMPLATE" ]] && NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.conf.template" + [[ -z "$NGINX_CUSTOM_TEMPLATE" ]] && NGINX_TEMPLATE="$(dirname $0)/templates/nginx.conf.template" eval "cat <<< \"$(< $NGINX_TEMPLATE)\" >> $NGINX_CONF" fi @@ -130,7 +130,7 @@ EOF if is_deployed "$APP"; then dokku_log_info1 "Running nginx-pre-reload" - pluginhook nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP + plugn trigger nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP dokku_log_verbose "Reloading nginx" validate_nginx && restart_nginx @@ -160,7 +160,7 @@ EOF fi ;; help | nginx:help) - cat && cat<, (Re)builds nginx config for given app EOF ;; diff --git a/plugins/nginx-vhosts/plugin.toml b/plugins/nginx-vhosts/plugin.toml new file mode 100644 index 000000000..7356a63d8 --- /dev/null +++ b/plugins/nginx-vhosts/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core nginx-vhosts plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/nginx-vhosts/post-deploy b/plugins/nginx-vhosts/post-deploy index 70b033b6e..e3fd84430 100755 --- a/plugins/nginx-vhosts/post-deploy +++ b/plugins/nginx-vhosts/post-deploy @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" -source "$PLUGIN_PATH/config/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" APP="$1" if [[ -f "$DOKKU_ROOT/$APP/IP.web.1" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT.web.1" ]]; then diff --git a/plugins/nginx-vhosts/post-domains-update b/plugins/nginx-vhosts/post-domains-update index 945057998..20abd9d5e 100755 --- a/plugins/nginx-vhosts/post-domains-update +++ b/plugins/nginx-vhosts/post-domains-update @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1" diff --git a/plugins/plugin/commands b/plugins/plugin/commands new file mode 100755 index 000000000..8df025c37 --- /dev/null +++ b/plugins/plugin/commands @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/plugin/functions" + +case "$1" in + plugin) + plugn list + ;; + + plugin: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) + if [[ $2 == "--core" ]]; then + export PLUGIN_PATH="$PLUGIN_CORE_PATH" + fi + plugn trigger dependencies + ;; + + plugin:update) + case "$2" in + https:*|git:*) + PLUGIN_GIT_URL="$2" + download_and_enable_plugin $PLUGIN_GIT_URL + plugn trigger update + ;; + *) + plugn trigger update + ;; + esac + ;; + + plugin:disable) + [[ -z $2 ]] && dokku_log_fail "Please specify a plugin to disable" + PLUGIN="$2" + disable_plugin "$PLUGIN" + ;; + + plugin:enable) + [[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable" + PLUGIN="$2" + enable_plugin "$PLUGIN" + ;; + + plugin:uninstall) + [[ -z $2 ]] && dokku_log_fail "Please specify a plugin to enable" + PLUGIN="$2" + uninstall_plugin "$PLUGIN" + ;; + + help | plugin:help) + cat<, Enable a previously disabled plugin + plugin:disable , Disable an installed plugin (third-party only) + plugin:uninstall , Uninstall a plugin (third-party only) +EOF + ;; + + *) + exit $DOKKU_NOT_IMPLEMENTED_EXIT + ;; + +esac + + diff --git a/plugins/plugin/functions b/plugins/plugin/functions new file mode 100755 index 000000000..a30c6dcc7 --- /dev/null +++ b/plugins/plugin/functions @@ -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" +} diff --git a/plugins/plugin/plugin.toml b/plugins/plugin/plugin.toml new file mode 100644 index 000000000..fbcfc4da7 --- /dev/null +++ b/plugins/plugin/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core plugin plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/ps/commands b/plugins/ps/commands index a24b10a58..61b5d25ae 100755 --- a/plugins/ps/commands +++ b/plugins/ps/commands @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" -source "$(dirname $0)/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/ps/functions" case "$1" in ps) @@ -14,7 +14,7 @@ case "$1" in dokku_log_info1_quiet "running processes in container: $CID" docker exec $DOKKU_RUN_OPTS $CID /bin/sh -c "ps auxwww" done - ;; + ;; ps:start) [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" @@ -28,7 +28,7 @@ case "$1" in else echo "App $APP already running" fi - ;; + ;; ps:stop) [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" @@ -43,14 +43,14 @@ case "$1" in else echo "App $APP already stopped" fi - ;; + ;; ps:rebuild) [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" APP="$2"; verify_app_name "$APP" - pluginhook -p receive-app $APP - ;; + plugn trigger receive-app $APP + ;; ps:rebuildall) shopt -s nullglob @@ -60,7 +60,7 @@ case "$1" in is_deployed $APP && dokku ps:rebuild $APP done shopt -u nullglob - ;; + ;; ps:restart) [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" @@ -70,7 +70,7 @@ case "$1" in ! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0 release_and_deploy "$APP" "$IMAGE_TAG" - ;; + ;; ps:restartall) shopt -s nullglob @@ -80,7 +80,7 @@ case "$1" in dokku ps:restart $APP done shopt -u nullglob - ;; + ;; ps:scale) [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" @@ -98,10 +98,10 @@ case "$1" in set_scale "$APP" "$@" release_and_deploy "$APP" "$IMAGE_TAG" fi - ;; + ;; help | ps:help) - cat && cat<, List processes running in app container(s) ps:scale = [=], Set how many instances of a given process to run ps:start , Start app container(s) diff --git a/plugins/ps/functions b/plugins/ps/functions index c21498f05..64f667210 100755 --- a/plugins/ps/functions +++ b/plugins/ps/functions @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/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" diff --git a/plugins/ps/plugin.toml b/plugins/ps/plugin.toml new file mode 100644 index 000000000..128e3456e --- /dev/null +++ b/plugins/ps/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core ps plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/ps/pre-deploy b/plugins/ps/pre-deploy index 80488ed13..84f132d89 100755 --- a/plugins/ps/pre-deploy +++ b/plugins/ps/pre-deploy @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" -source "$(dirname $0)/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/ps/functions" APP="$1" diff --git a/plugins/shell/commands b/plugins/shell/commands index cdb05637a..0d3b73fbd 100755 --- a/plugins/shell/commands +++ b/plugins/shell/commands @@ -30,15 +30,16 @@ case "$1" in [[ "$line" != "$(fc -ln -1 | trim)" ]] && history -s "$line" case $CMD in - # shell builtins + # shell builtins clear) clear ;; + quit|exit) break ;; - # Not a built-in, run as regular dokku command + # Not a built-in, run as regular dokku command *) dokku $line || true esac @@ -47,7 +48,7 @@ case "$1" in ;; help | shell:help) - cat && cat< /dev/null if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]]; then dokku receive "$APP" "dockerfile" "$TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/" diff --git a/plugins/tar/plugin.toml b/plugins/tar/plugin.toml new file mode 100644 index 000000000..4454166ab --- /dev/null +++ b/plugins/tar/plugin.toml @@ -0,0 +1,4 @@ +[plugin] +description = "dokku core tar plugin" +version = "0.4.0" +[plugin.config] diff --git a/plugins/tar/receive-app b/plugins/tar/receive-app index 0bf09425b..e84dc3dba 100755 --- a/plugins/tar/receive-app +++ b/plugins/tar/receive-app @@ -1,12 +1,12 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$PLUGIN_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" APP="$1"; REV="$2" # Don't trigger tar build if there is no tarball. if [ ! -f "$DOKKU_ROOT/$APP/src.tar" ]; then - cat || true + true else dokku tar-build $APP fi diff --git a/tests.mk b/tests.mk index 65b2c6f87..56f22fb2a 100644 --- a/tests.mk +++ b/tests.mk @@ -65,7 +65,7 @@ lint: # SC2001: See if you can use ${variable//search/replace} instead. - https://github.com/koalaman/shellcheck/wiki/SC2001 @echo linting... @$(QUIET) shellcheck -e SC2029 ./contrib/dokku_client.sh - @$(QUIET) find . -not -path '*/\.*' | xargs file | egrep "shell|bash" | grep -v directory | awk '{ print $$1 }' | sed 's/://g' | grep -v dokku_client.sh | xargs shellcheck -e SC2034,SC2086,SC2143,SC2001 + @$(QUIET) find . -not -path '*/\.*' | xargs file | egrep "shell|bash" | egrep -v "directory|toml" | awk '{ print $$1 }' | sed 's/://g' | grep -v dokku_client.sh | xargs shellcheck -e SC2034,SC2086,SC2143,SC2001 unit-tests: @echo running unit tests... diff --git a/tests/unit/core_ports.bats b/tests/unit/core_ports.bats index 696159ce8..79f6c1b95 100644 --- a/tests/unit/core_ports.bats +++ b/tests/unit/core_ports.bats @@ -165,7 +165,7 @@ check_urls() { } @test "(core) port exposure (dockerfile raw port)" { - source "$PLUGIN_PATH/common/functions" + source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cat< $DOCKERFILE EXPOSE 3001/udp EXPOSE 3003 @@ -178,7 +178,7 @@ EOF } @test "(core) port exposure (dockerfile tcp port)" { - source "$PLUGIN_PATH/common/functions" + source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cat< $DOCKERFILE EXPOSE 3001/udp EXPOSE 3000/tcp diff --git a/tests/unit/plugin.bats b/tests/unit/plugin.bats new file mode 100644 index 000000000..dfa0a849d --- /dev/null +++ b/tests/unit/plugin.bats @@ -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 +} diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 9bb6c4ae4..a552569dd 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -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