Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c05aa74a3e | ||
|
|
d112144293 | ||
|
|
30de0727ab | ||
|
|
8823baf480 | ||
|
|
d470ade7a7 | ||
|
|
66e8279dca | ||
|
|
969a9cdcb0 | ||
|
|
5620147f89 | ||
|
|
dda9ed6d55 | ||
|
|
76e0d5fd87 | ||
|
|
7382058ecb | ||
|
|
0a8d599965 | ||
|
|
d143bb48b0 | ||
|
|
e78cc9bd36 |
@@ -279,6 +279,9 @@ service_container_rm() {
|
|||||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
|
|
||||||
service_stop "$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"
|
dokku_log_verbose_quiet "Removing container"
|
||||||
if ! docker rm "$SERVICE_NAME" > /dev/null 2>&1; then
|
if ! docker rm "$SERVICE_NAME" > /dev/null 2>&1; then
|
||||||
dokku_log_fail "Unable to remove container for service $SERVICE"
|
dokku_log_fail "Unable to remove container for service $SERVICE"
|
||||||
@@ -471,24 +474,24 @@ service_parse_args() {
|
|||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
shift
|
shift
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--config-options") set -- "$@" "-c" ;;
|
"--alias") set -- "$@" "-a" ;;
|
||||||
"--custom-env") set -- "$@" "-C" ;;
|
"--config-options") set -- "$@" "-c" ;;
|
||||||
"--image") set -- "$@" "-i" ;;
|
"--custom-env") set -- "$@" "-C" ;;
|
||||||
"--image-version") set -- "$@" "-I" ;;
|
"--database") set -- "$@" "-d" ;;
|
||||||
"--password") set -- "$@" "-p" ;;
|
"--image-version") set -- "$@" "-I" ;;
|
||||||
"--root-password") set -- "$@" "-r" ;;
|
"--image") set -- "$@" "-i" ;;
|
||||||
|
"--memory") set -- "$@" "-m" ;;
|
||||||
"--alias") set -- "$@" "-a" ;;
|
"--password") set -- "$@" "-p" ;;
|
||||||
"--database") set -- "$@" "-d" ;;
|
"--querystring") set -- "$@" "-q" ;;
|
||||||
"--memory") set -- "$@" "-m" ;;
|
"--restart-apps") set -- "$@" "-R" ;;
|
||||||
"--querystring") set -- "$@" "-q" ;;
|
"--root-password") set -- "$@" "-r" ;;
|
||||||
"--user") set -- "$@" "-u" ;;
|
"--user") set -- "$@" "-u" ;;
|
||||||
*) set -- "$@" "$arg"
|
*) set -- "$@" "$arg"
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
OPTIND=1
|
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
|
case "$opt" in
|
||||||
a)
|
a)
|
||||||
SERVICE_ALIAS="${OPTARG^^}"; export SERVICE_ALIAS="${SERVICE_ALIAS%_URL}"
|
SERVICE_ALIAS="${OPTARG^^}"; export SERVICE_ALIAS="${SERVICE_ALIAS%_URL}"
|
||||||
@@ -509,6 +512,8 @@ service_parse_args() {
|
|||||||
;;
|
;;
|
||||||
q) export SERVICE_QUERYSTRING=${OPTARG#"?"}
|
q) export SERVICE_QUERYSTRING=${OPTARG#"?"}
|
||||||
;;
|
;;
|
||||||
|
R) export SERVICE_RESTART_APPS=$OPTARG
|
||||||
|
;;
|
||||||
r) export SERVICE_ROOT_PASSWORD=$OPTARG
|
r) export SERVICE_ROOT_PASSWORD=$OPTARG
|
||||||
;;
|
;;
|
||||||
u) export SERVICE_USER=$OPTARG
|
u) export SERVICE_USER=$OPTARG
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ service_import() {
|
|||||||
if [[ -t 0 ]]; then
|
if [[ -t 0 ]]; then
|
||||||
dokku_log_fail "No data provided on stdin."
|
dokku_log_fail "No data provided on stdin."
|
||||||
fi
|
fi
|
||||||
docker exec -i "$SERVICE_NAME" env PGPASSWORD="$PASSWORD" pg_restore -h localhost -cO -d "$DATABASE_NAME" -U postgres -w
|
docker exec -i "$SERVICE_NAME" env PGPASSWORD="$PASSWORD" pg_restore -h localhost -cO --if-exists -d "$DATABASE_NAME" -U postgres -w
|
||||||
}
|
}
|
||||||
|
|
||||||
service_start() {
|
service_start() {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ fn-help-contents() {
|
|||||||
fn-help-contents-subcommand() {
|
fn-help-contents-subcommand() {
|
||||||
declare SUBCOMMAND="$1" FULL_OUTPUT="$2"
|
declare SUBCOMMAND="$1" FULL_OUTPUT="$2"
|
||||||
local TMPDIR=$(mktemp -d)
|
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
|
local BOLD CMD_OUTPUT CYAN EXAMPLE LIGHT_GRAY NORMAL
|
||||||
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[plugin]
|
[plugin]
|
||||||
description = "dokku postgres service plugin"
|
description = "dokku postgres service plugin"
|
||||||
version = "1.4.0"
|
version = "1.4.6"
|
||||||
[plugin.config]
|
[plugin.config]
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ service-clone-cmd() {
|
|||||||
#E dokku $PLUGIN_COMMAND_PREFIX:clone lolipop lolipop-2
|
#E dokku $PLUGIN_COMMAND_PREFIX:clone lolipop lolipop-2
|
||||||
#A service, service to run command against
|
#A service, service to run command against
|
||||||
#A new-service, name of new service
|
#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 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 -p|--password PASSWORD, override the user-level service password
|
||||||
#F -r|--root-password PASSWORD, override the root-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>"
|
declare desc="create container <new-name> then copy data from <name> into <new-name>"
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ service-create-cmd() {
|
|||||||
#E export ${PLUGIN_DEFAULT_ALIAS}_CUSTOM_ENV="USER=alpha;HOST=beta"
|
#E export ${PLUGIN_DEFAULT_ALIAS}_CUSTOM_ENV="USER=alpha;HOST=beta"
|
||||||
#E dokku $PLUGIN_COMMAND_PREFIX:create lolipop
|
#E dokku $PLUGIN_COMMAND_PREFIX:create lolipop
|
||||||
#A service, service to run command against
|
#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 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 -p|--password PASSWORD, override the user-level service password
|
||||||
#F -r|--root-password PASSWORD, override the root-level service password
|
#F -r|--root-password PASSWORD, override the root-level service password
|
||||||
declare desc="create a $PLUGIN_SERVICE service"
|
declare desc="create a $PLUGIN_SERVICE service"
|
||||||
|
|||||||
@@ -3,17 +3,19 @@ source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
|||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_BASE_PATH/common/functions"
|
source "$PLUGIN_BASE_PATH/common/functions"
|
||||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||||
|
|
||||||
service-upgrade-cmd() {
|
service-upgrade-cmd() {
|
||||||
#E you can upgrade an existing service to a new image or image-version
|
#E you can upgrade an existing service to a new image or image-version
|
||||||
#E dokku $PLUGIN_COMMAND_PREFIX:upgrade lolipop
|
#E dokku $PLUGIN_COMMAND_PREFIX:upgrade lolipop
|
||||||
#A service, service to run command against
|
#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 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 -R|--restart-apps "true", whether to force an app restart
|
||||||
declare desc="upgrade service <service> to the specified versions"
|
declare desc="upgrade service <service> to the specified versions"
|
||||||
local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||||
declare SERVICE="$1" CLONE_FLAGS_LIST="${@:2}"
|
declare SERVICE="$1" UPGRADE_FLAG_LIST="${@:2}"
|
||||||
|
|
||||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||||
verify_service_name "$SERVICE"
|
verify_service_name "$SERVICE"
|
||||||
@@ -29,9 +31,24 @@ service-upgrade-cmd() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
dokku_log_info2 "Upgrading $SERVICE to $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
|
dokku_log_info2 "Upgrading $SERVICE to $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
|
||||||
|
if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then
|
||||||
|
dokku_log_info2 "Stopping all linked services"
|
||||||
|
for app in $(service_linked_apps "$SERVICE"); do
|
||||||
|
ps_stop "$app"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
dokku_log_info2 "Stopping $SERVICE"
|
dokku_log_info2 "Stopping $SERVICE"
|
||||||
service_container_rm "$SERVICE"
|
service_container_rm "$SERVICE"
|
||||||
service_start "$SERVICE" "${@:2}"
|
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
|
||||||
|
ps_start "$app"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
dokku_log_info2 "Done"
|
dokku_log_info2 "Done"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ teardown() {
|
|||||||
export ECHO_DOCKER_COMMAND="true"
|
export ECHO_DOCKER_COMMAND="true"
|
||||||
run dokku "$PLUGIN_COMMAND_PREFIX:import" l < "$PLUGIN_DATA_ROOT/fake.dump"
|
run dokku "$PLUGIN_COMMAND_PREFIX:import" l < "$PLUGIN_DATA_ROOT/fake.dump"
|
||||||
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||||
assert_output "docker exec -i dokku.postgres.l env PGPASSWORD=$password pg_restore -h localhost -cO -d l -U postgres -w"
|
assert_output "docker exec -i dokku.postgres.l env PGPASSWORD=$password pg_restore -h localhost -cO --if-exists -d l -U postgres -w"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user