Compare commits

...

34 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
f3ba0d51f6 Release 1.4.10 2018-12-02 16:17:52 -05:00
Jose Diaz-Gonzalez
39a7864022 fix: correct issues where docker ps is truncated
This should actually be refactored to avoid the grep call completely, but the current fix will correct the issue for now.

Refs dokku/dokku-postgres#131
2018-12-02 14:29:24 -05:00
Jose Diaz-Gonzalez
8061f0c50a fix: correct issues where docker ps is truncated
This should actually be refactored to avoid the grep call completely, but the current fix will correct the issue for now.

Refs dokku/dokku-postgres#131
2018-12-02 05:21:10 -05:00
Jose Diaz-Gonzalez
aa1a23d5a1 fix: ensure any backup cron files are deleted when the service is destroyed
Closes dokku/dokku-redis#118
2018-12-02 05:10:06 -05:00
Jose Diaz-Gonzalez
5e5ad6d472 fix: clean up backup containers after use
Closes dokku/dokku#104
2018-12-02 04:46:52 -05:00
Jose Diaz-Gonzalez
733e14ee73 fix: correct documentation around the passphrase parameter
Closes dokku/dokku-mysql#101
2018-12-02 04:33:58 -05:00
Jose Diaz-Gonzalez
fc018c65f1 Release 1.4.9 2018-10-11 14:53:12 -04:00
Jose Diaz-Gonzalez
598ea1f526 fix: correct issue where help output isnt colorized by default 2018-10-11 14:20:03 -04:00
Jose Diaz-Gonzalez
b7724b826c fix: correct issues in upgrade and fix tests 2018-10-11 14:16:47 -04:00
Jose Diaz-Gonzalez
0cee8bd31a Release 1.4.8 2018-10-11 00:05:24 -04:00
Jose Diaz-Gonzalez
765f44dcfe feat: skip upgrade if service is already up to date 2018-10-11 00:04:52 -04:00
Jose Diaz-Gonzalez
c9ea129035 Release 1.4.7 2018-10-10 23:54:38 -04:00
Jose Diaz-Gonzalez
00b290346e feat: allow removal of header from :list subcommand 2018-10-10 23:54:08 -04:00
Jose Diaz-Gonzalez
d40e5bbb35 Release 1.4.6 2018-10-10 23:48:44 -04:00
Jose Diaz-Gonzalez
4689d223b6 fix: respect various ways of not wanting 'fancy' output.
Closes dokku/dokku-daemon#19
Closes dokku/dokku-daemon#22
2018-10-10 23:47:46 -04:00
Jose Diaz-Gonzalez
0a7f86a21b Release 1.4.5 2018-10-10 23:32:25 -04:00
Jose Diaz-Gonzalez
c96d25706b fix: ensure flags are properly represented in help output 2018-10-10 23:31:52 -04:00
Jose Diaz-Gonzalez
4624d5a790 Release 1.4.4 2018-10-10 23:27:27 -04:00
Jose Diaz-Gonzalez
5887a018d0 fix: correct issue where temp help output files were being placed in incorrect directory 2018-10-10 23:23:10 -04:00
Jose Diaz-Gonzalez
bbe8fee561 Release 1.4.3 2018-10-10 23:18:32 -04:00
Jose Diaz-Gonzalez
5f2e184d68 feat: add support for restarting containers to ensure links continue to work properly when the application has resolved dns of the link 2018-10-10 23:14:45 -04:00
Jose Diaz-Gonzalez
8a8857374c fix: handle case where container being removed does not exist 2018-10-10 22:03:44 -04:00
Jose Diaz-Gonzalez
2176ab836e Release 1.4.2 2018-10-10 03:03:32 -04:00
Jose Diaz-Gonzalez
1c35653e7e fix: correct short-flag for image-version and custom-env 2018-10-10 03:02:56 -04:00
Jose Diaz-Gonzalez
7c17773fb2 Release 1.4.1 2018-10-10 03:01:09 -04:00
Jose Diaz-Gonzalez
980e7d1650 fix: correct name for upgrade flags in help output 2018-10-10 03:00:22 -04:00
Jose Diaz-Gonzalez
64394619b5 Release 1.4.0 2018-10-10 02:59:16 -04:00
Jose Diaz-Gonzalez
a39ade3161 chore: correct verbiage around upgrades 2018-10-10 02:54:34 -04:00
Jose Diaz-Gonzalez
20dd893a77 fix: pass correct variable for upgrade command 2018-10-10 02:49:30 -04:00
Jose Diaz-Gonzalez
e089d0d03d fix: correct check for existing image 2018-10-10 02:42:43 -04:00
Jose Diaz-Gonzalez
ab9da6349e fix: do not force-set plugin image and version to existing image and version 2018-10-10 02:39:10 -04:00
Jose Diaz-Gonzalez
c2ed798db0 chore: remove unnecessary call 2018-10-10 02:32:59 -04:00
Jose Diaz-Gonzalez
63fc31807c Merge pull request #100 from dokku/upgrade-service-image-version
feat: add ability to upgrade service image and image-version
2018-10-10 02:10:39 -04:00
Jose Diaz-Gonzalez
284ffa3177 feat: add ability to upgrade service image and image-version 2018-10-10 00:13:59 -04:00
12 changed files with 173 additions and 59 deletions

View File

@@ -23,7 +23,7 @@ mysql:backup-auth <name> <aws_access_key_id> <aws_secret_access_key> (<aws_defau
mysql:backup-deauth <name> Removes backup authentication for the mysql service
mysql:backup-schedule <name> <schedule> <bucket> Schedules a backup of the mysql service
mysql:backup-schedule-cat <name> Cat the contents of the configured backup cronfile for the service
mysql:backup-set-encryption <name> <encryption_key> Sets up GPG encryption for future backups of the mysql service
mysql:backup-set-encryption <name> <passphrase> Set a GPG passphrase for backups
mysql:backup-unschedule <name> Unschedules the backup of the mysql service
mysql:backup-unset-encryption <name> Removes backup encryption for future backups of the mysql service
mysql:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name>
@@ -46,6 +46,7 @@ mysql:start <name> Start a previously stopped mysql service
mysql:stop <name> Stop a running mysql service
mysql:unexpose <name> Unexpose a previously exposed mysql service
mysql:unlink <name> <app> Unlink the mysql service from the app
mysql:upgrade <name> Upgrade service <service> to the specified version
```
## usage

View File

@@ -183,7 +183,7 @@ service_backup() {
fi
# shellcheck disable=SC2086
docker run $BACKUP_PARAMETERS dokkupaas/s3backup:0.8.0
docker run --rm $BACKUP_PARAMETERS dokkupaas/s3backup:0.8.0
}
service_backup_auth() {
@@ -273,6 +273,22 @@ service_backup_unset_encryption() {
rm -rf "$SERVICE_BACKUP_ENCRYPTION_ROOT"
}
service_container_rm() {
declare desc="Stops a service and removes the running container"
declare SERVICE="$1"
local SERVICE_NAME="$(get_service_name "$SERVICE")"
service_stop "$SERVICE"
local ID=$(docker inspect "$SERVICE_NAME" -f '{{ .ID }}' 2> /dev/null || true)
[[ -z "$ID" ]] && return 0
dokku_log_verbose_quiet "Removing container"
docker update --restart=no "$SERVICE_NAME" > /dev/null 2>&1
if ! docker rm "$SERVICE_NAME" > /dev/null 2>&1; then
dokku_log_fail "Unable to remove container for service $SERVICE"
fi
}
service_enter() {
declare desc="enters running app container of specified proc type"
declare SERVICE="$1" && shift 1
@@ -300,6 +316,17 @@ service_exposed_ports() {
done
}
service_image_exists() {
declare desc="Checks if the current image exists"
local IMAGE="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
if [[ "$(docker images -q "$IMAGE" 2> /dev/null)" == "" ]]; then
return 1
fi
return 0
}
service_info() {
declare desc="Retrieves information about a given service"
declare SERVICE="$1" INFO_FLAG="$2"
@@ -414,7 +441,11 @@ service_list() {
if [[ -z $SERVICES ]]; then
dokku_log_warn "There are no $PLUGIN_SERVICE services"
else
LIST="NAME,VERSION,STATUS,EXPOSED PORTS,LINKS\n"
LIST=""
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
LIST="NAME,VERSION,STATUS,EXPOSED PORTS,LINKS\n"
fi
for SERVICE in $SERVICES; do
LIST+="$SERVICE,$(service_version "$SERVICE"),$(service_status "$SERVICE"),$(service_exposed_ports "$SERVICE"),$(service_linked_apps "$SERVICE")\n"
done
@@ -448,24 +479,24 @@ service_parse_args() {
for arg in "$@"; do
shift
case "$arg" in
"--config-options") set -- "$@" "-c" ;;
"--custom-env") set -- "$@" "-C" ;;
"--image") set -- "$@" "-i" ;;
"--image-version") set -- "$@" "-I" ;;
"--password") set -- "$@" "-p" ;;
"--root-password") set -- "$@" "-r" ;;
"--alias") set -- "$@" "-a" ;;
"--database") set -- "$@" "-d" ;;
"--memory") set -- "$@" "-m" ;;
"--querystring") set -- "$@" "-q" ;;
"--user") set -- "$@" "-u" ;;
*) set -- "$@" "$arg"
"--alias") set -- "$@" "-a" ;;
"--config-options") set -- "$@" "-c" ;;
"--custom-env") set -- "$@" "-C" ;;
"--database") set -- "$@" "-d" ;;
"--image-version") set -- "$@" "-I" ;;
"--image") set -- "$@" "-i" ;;
"--memory") set -- "$@" "-m" ;;
"--password") set -- "$@" "-p" ;;
"--querystring") set -- "$@" "-q" ;;
"--restart-apps") set -- "$@" "-R" ;;
"--root-password") set -- "$@" "-r" ;;
"--user") set -- "$@" "-u" ;;
*) set -- "$@" "$arg"
esac
done
OPTIND=1
while getopts "a:c:C:d:i:I:m:p:q:r:u:" opt; do
while getopts "a:c:C:d:i:I:m:p:q:R:r:u:" opt; do
case "$opt" in
a)
SERVICE_ALIAS="${OPTARG^^}"; export SERVICE_ALIAS="${SERVICE_ALIAS%_URL}"
@@ -486,6 +517,8 @@ service_parse_args() {
;;
q) export SERVICE_QUERYSTRING=${OPTARG#"?"}
;;
R) export SERVICE_RESTART_APPS=$OPTARG
;;
r) export SERVICE_ROOT_PASSWORD=$OPTARG
;;
u) export SERVICE_USER=$OPTARG
@@ -634,7 +667,7 @@ service_stop() {
declare SERVICE="$1"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE";
local SERVICE_NAME="$(get_service_name "$SERVICE")"
local ID=$(docker ps -f status=running | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
local ID=$(docker ps -f status=running --no-trunc | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
[[ -z $ID ]] && dokku_log_warn "Service is already stopped" && return 0
if [[ -n $ID ]]; then

View File

@@ -29,7 +29,7 @@ service_create() {
service_parse_args "${@:2}"
if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " ; then
if ! service_image_exists "$SERVICE"; then
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
dokku_log_warn " docker pull ${IMAGE}" 1>&2
@@ -119,15 +119,14 @@ service_start() {
local QUIET="$2"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local SERVICE_NAME="$(get_service_name "$SERVICE")"
local ID=$(docker ps -f status=running | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
local ID=$(docker ps -f status=running --no-trunc | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
if [[ -n $ID ]]; then
[[ -z $QUIET ]] && dokku_log_warn "Service is already started"
return 0
fi
dokku_log_info2_quiet "Starting container"
local PREVIOUS_ID=$(docker ps -f status=exited | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
local IMAGE_EXISTS=$(docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " && true)
local PREVIOUS_ID=$(docker ps -f status=exited --no-trunc | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
local ROOTPASSWORD="$(cat "$SERVICE_ROOT/ROOTPASSWORD")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")"
@@ -135,7 +134,7 @@ service_start() {
docker start "$PREVIOUS_ID" > /dev/null
service_port_unpause "$SERVICE"
dokku_log_info2 "Container started"
elif $IMAGE_EXISTS && [[ -n "$ROOTPASSWORD" ]] && [[ -n "$PASSWORD" ]]; then
elif service_image_exists "$SERVICE" && [[ -n "$ROOTPASSWORD" ]] && [[ -n "$PASSWORD" ]]; then
service_create_container "$SERVICE"
else
dokku_log_verbose_quiet "Neither container nor valid configuration exists for $SERVICE"

View File

@@ -32,10 +32,10 @@ fn-help-all() {
FULL_OUTPUT=true
if [[ "$CMD" = "$PLUGIN_COMMAND_PREFIX:help" ]] || [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX" ]] || [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX:default" ]] ; then
BOLD="$(tput bold)"
NORMAL="\033[m"
BLUE="\033[0;34m"
CYAN="\033[1;36m"
BOLD="$(fn-help-fancy-tput bold)"
NORMAL="$(fn-help-fancy-color "\033[m")"
BLUE="$(fn-help-fancy-color "\033[0;34m")"
CYAN="$(fn-help-fancy-color "\033[1;36m")"
if [[ -n "$SUBCOMMAND" ]] && [[ "$SUBCOMMAND" != "--all" ]]; then
fn-help-contents-subcommand "$SUBCOMMAND" "$FULL_OUTPUT"
return "$?"
@@ -76,7 +76,7 @@ fn-help-contents() {
fn-help-contents-subcommand() {
declare SUBCOMMAND="$1" FULL_OUTPUT="$2"
local TMPDIR=$(mktemp -d)
local UNCLEAN_FILE="${TMPDIR}cmd-unclean" CLEAN_FILE="${TMPDIR}cmd-clean"
local UNCLEAN_FILE="${TMPDIR}/cmd-unclean" CLEAN_FILE="${TMPDIR}/cmd-clean"
local BOLD CMD_OUTPUT CYAN EXAMPLE LIGHT_GRAY NORMAL
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
@@ -95,12 +95,12 @@ fn-help-contents-subcommand() {
desc="$(grep desc "$CLEAN_FILE" | head -1)"
eval "$desc"
BLUE="\033[0;34m"
BOLD="$(tput bold)"
CYAN="\033[1;36m"
NORMAL="\033[m"
LIGHT_GRAY="\033[2;37m"
LIGHT_RED="\033[1;31m"
BLUE="$(fn-help-fancy-color "\033[0;34m")"
BOLD="$(fn-help-fancy-tput bold)"
CYAN="$(fn-help-fancy-color "\033[1;36m")"
NORMAL="$(fn-help-fancy-color "\033[m")"
LIGHT_GRAY="$(fn-help-fancy-color "\033[2;37m")"
LIGHT_RED="$(fn-help-fancy-color "\033[1;31m")"
CMD_OUTPUT="$(echo -e " ${PLUGIN_COMMAND_PREFIX}${cmd_line}, ${LIGHT_GRAY}${desc}${NORMAL}")"
if [[ "$FULL_OUTPUT" != "true" ]]; then
echo "$CMD_OUTPUT"
@@ -139,6 +139,26 @@ fn-help-contents-subcommand() {
return 0
}
fn-help-fancy-tput() {
declare desc="A wrapper around tput"
if [[ -n "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then
return
fi
tput "$@"
}
fn-help-fancy-color() {
declare desc="A wrapper around colors"
if [[ -n "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then
return
fi
echo "$@"
}
fn-help-list-example() {
# shellcheck disable=SC2034
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
@@ -153,8 +173,8 @@ fn-help-subcommand-args() {
local argline arglist args argpos BLUE NORMAL
if [[ "$FULL_OUTPUT" == "true" ]]; then
BLUE="\033[0;34m"
NORMAL="\033[m"
BLUE="$(fn-help-fancy-color "\033[0;34m")"
NORMAL="$(fn-help-fancy-color "\033[m")"
fi
argline=$(grep declare "$FUNC_FILE" | grep -v "declare desc" | head -1 || true)
arglist=($(echo -e "${argline// /"\n"}" | awk -F= '/=/{print ""$1""}'))
@@ -199,12 +219,12 @@ fn-help-subcommand-example() {
return 0
fi
BOLD="$(tput bold)"
BOLD="$(fn-help-fancy-tput bold)"
LAST_LINE=""
LIGHT_GRAY="\033[2;37m"
OTHER_GRAY="\033[7;37m"
LIGHT_GRAY="$(fn-help-fancy-color "\033[2;37m")"
OTHER_GRAY="$(fn-help-fancy-color "\033[7;37m")"
NEWLINE=""
NORMAL="\033[m"
NORMAL="$(fn-help-fancy-color "\033[m")"
_fn-help-apply-shell-expansion "$EXAMPLE" | while read -r line; do
line="$(echo "$line" | cut -c 4-)"
if [[ "$line" == export* ]] || [[ "$line" == dokku* ]]; then
@@ -234,8 +254,8 @@ fn-help-subcommand-list-args() {
return 0
fi
NORMAL="\033[m"
LIGHT_GRAY="\033[2;37m"
NORMAL="$(fn-help-fancy-color "\033[m")"
LIGHT_GRAY="$(fn-help-fancy-color "\033[2;37m")"
_fn-help-apply-shell-expansion "$FLAGS" | while read -r line; do
echo -e "$(echo "$line" | cut -d',' -f1),${LIGHT_GRAY}$(echo "$line" | cut -d',' -f2-)${NORMAL}"
@@ -251,8 +271,8 @@ fn-help-subcommand-list-flags() {
return 0
fi
NORMAL="\033[m"
LIGHT_GRAY="\033[2;37m"
NORMAL="$(fn-help-fancy-color "\033[m")"
LIGHT_GRAY="$(fn-help-fancy-color "\033[2;37m")"
_fn-help-apply-shell-expansion "$FLAGS" | while read -r line; do
echo -e "$(echo "$line" | cut -d',' -f1),${LIGHT_GRAY}$(echo "$line" | cut -d',' -f2-)${NORMAL}"

View File

@@ -1,4 +1,4 @@
[plugin]
description = "dokku mysql service plugin"
version = "1.3.0"
version = "1.4.10"
[plugin.config]

View File

@@ -5,19 +5,19 @@ source "$PLUGIN_BASE_PATH/common/functions"
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
service-backup-set-encryption-cmd() {
#E set a GPG encryption key for backups
#E set a GPG passphrase for backups
#E dokku $PLUGIN_COMMAND_PREFIX:backup-set-encryption lolipop
#A service, service to run command against
#A encryption-key, a GPG encryption key
#A passphrase, a GPG-compatible passphrase
declare desc="sets encryption for all future backups of $PLUGIN_SERVICE service"
local cmd="$PLUGIN_COMMAND_PREFIX:backup-set-encryption" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
declare SERVICE="$1" ENCRYPTION_KEY="$2"
declare SERVICE="$1" PASSPHRASE="$2"
is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented"
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
[[ -z "$ENCRYPTION_KEY" ]] && dokku_log_fail "Please specify a GPG encryption key"
[[ -z "$PASSPHRASE" ]] && dokku_log_fail "Please specify a GPG backup passphrase"
verify_service_name "$SERVICE"
service_backup_set_encryption "$SERVICE" "$ENCRYPTION_KEY"
service_backup_set_encryption "$SERVICE" "$PASSPHRASE"
}
service-backup-set-encryption-cmd "$@"

View File

@@ -9,9 +9,9 @@ service-clone-cmd() {
#E dokku $PLUGIN_COMMAND_PREFIX:clone lolipop lolipop-2
#A service, service to run command against
#A new-service, name of new service
#F -c|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
#F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
#F -i|--image IMAGE, the image name to start the service with
#F -i|--image-version IMAGE_VERSION, the image version to start the service with
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
#F -p|--password PASSWORD, override the user-level service password
#F -r|--root-password PASSWORD, override the root-level service password
declare desc="create container <new-name> then copy data from <name> into <new-name>"

View File

@@ -17,9 +17,9 @@ service-create-cmd() {
#E export ${PLUGIN_DEFAULT_ALIAS}_CUSTOM_ENV="USER=alpha;HOST=beta"
#E dokku $PLUGIN_COMMAND_PREFIX:create lolipop
#A service, service to run command against
#F -c|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
#F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
#F -i|--image IMAGE, the image name to start the service with
#F -i|--image-version IMAGE_VERSION, the image version to start the service with
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
#F -p|--password PASSWORD, override the user-level service password
#F -r|--root-password PASSWORD, override the root-level service password
declare desc="create a $PLUGIN_SERVICE service"

View File

@@ -38,6 +38,7 @@ service-destroy-cmd() {
fi
dokku_log_info2_quiet "Deleting $SERVICE"
service_backup_unschedule "$SERVICE"
if [[ -n $(docker ps -aq -f name="$SERVICE_NAME") ]]; then
dokku_log_verbose_quiet "Deleting container data"
service_stop "$SERVICE"

61
subcommands/upgrade Executable file
View File

@@ -0,0 +1,61 @@
#!/usr/bin/env bash
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_BASE_PATH/common/functions"
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
service-upgrade-cmd() {
#E you can upgrade an existing service to a new image or image-version
#E dokku $PLUGIN_COMMAND_PREFIX:upgrade lolipop
#A service, service to run command against
#F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
#F -i|--image IMAGE, the image name to start the service with
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
#F -R|--restart-apps "true", whether to force an app restart
declare desc="upgrade service <service> to the specified versions"
local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
declare SERVICE="$1" UPGRADE_FLAGS_LIST="${@:2}"
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
verify_service_name "$SERVICE"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
service_parse_args "${@:2}"
if ! service_image_exists "$SERVICE"; then
dokku_log_fail "Unable to proceed with upgrade, image ${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION} does not exist"
fi
local NEW_PLUGIN_IMAGE_TAG="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
if [[ "$(service_version "$SERVICE")" == "$NEW_PLUGIN_IMAGE_TAG" ]]; then
dokku_log_info1 "Service $SERVICE already running $NEW_PLUGIN_IMAGE_TAG"
return
fi
dokku_log_info2 "Upgrading $SERVICE to $NEW_PLUGIN_IMAGE_TAG"
if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then
dokku_log_info2 "Stopping all linked services"
for app in $(service_linked_apps "$SERVICE"); do
[[ "$app" == "-" ]] && continue
ps_stop "$app"
done
fi
dokku_log_info2 "Stopping $SERVICE"
service_container_rm "$SERVICE"
service_start "$SERVICE" "${@:2}"
if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then
dokku_log_info2 "Starting all linked services"
for app in $(service_linked_apps "$SERVICE"); do
[[ "$app" == "-" ]] && continue
ps_start "$app"
done
fi
dokku_log_info2 "Done"
}
service-upgrade-cmd "$@"

View File

@@ -52,7 +52,7 @@ teardown() {
check_value="Deploy options: --restart=on-failure:10"
fi
options=$(dokku $report_action my_app | xargs)
options=$(dokku --quiet $report_action my_app | xargs)
assert_equal "$options" "$check_value"
}

1
tests/test_helper.bash Normal file → Executable file
View File

@@ -1,5 +1,4 @@
#!/usr/bin/env bash
export DOKKU_QUIET_OUTPUT=1
export DOKKU_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku"
export DOKKU_VERSION=${DOKKU_VERSION:-"master"}
export PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/bin:$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku:$PATH"