From 6fe30de9f238f3bb92ac24d7be999815cec5fa3b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 30 May 2019 11:06:25 -0400 Subject: [PATCH] chore: run shfmt --- commands | 3 +- common-functions | 169 +++++++++++++++------------- functions | 24 ++-- help-functions | 27 ++--- install | 7 +- pre-delete | 5 +- subcommands/app-links | 6 +- subcommands/backup | 6 +- subcommands/backup-auth | 6 +- subcommands/backup-deauth | 6 +- subcommands/backup-schedule | 6 +- subcommands/backup-schedule-cat | 6 +- subcommands/backup-set-encryption | 6 +- subcommands/backup-unschedule | 6 +- subcommands/backup-unset-encryption | 6 +- subcommands/clone | 12 +- subcommands/connect | 6 +- subcommands/create | 8 +- subcommands/destroy | 9 +- subcommands/enter | 6 +- subcommands/exists | 6 +- subcommands/export | 6 +- subcommands/expose | 6 +- subcommands/import | 6 +- subcommands/info | 6 +- subcommands/link | 6 +- subcommands/linked | 6 +- subcommands/list | 6 +- subcommands/logs | 6 +- subcommands/promote | 6 +- subcommands/restart | 6 +- subcommands/start | 6 +- subcommands/stop | 6 +- subcommands/unexpose | 6 +- subcommands/unlink | 6 +- subcommands/upgrade | 6 +- tests/setup.sh | 3 +- tests/test_helper.bash | 16 ++- 38 files changed, 267 insertions(+), 178 deletions(-) diff --git a/commands b/commands index 6253c45..7aa345c 100755 --- a/commands +++ b/commands @@ -2,7 +2,8 @@ source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" [[ " help $PLUGIN_COMMAND_PREFIX:help $PLUGIN_COMMAND_PREFIX $PLUGIN_COMMAND_PREFIX:default " == *" $1 "* ]] || [[ "$1" == "$PLUGIN_COMMAND_PREFIX:"* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" source "$PLUGIN_BASE_PATH/common/functions" -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/help-functions" diff --git a/common-functions b/common-functions index 62b8d13..5d01e26 100755 --- a/common-functions +++ b/common-functions @@ -1,11 +1,12 @@ #!/usr/bin/env bash -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_AVAILABLE_PATH/config/functions" docker_ports_options() { declare desc="Exports a list of exposed ports" declare PORTS=("$@") - for (( i=0; i < ${#PLUGIN_DATASTORE_PORTS[@]}; i++ )); do + for ((i = 0; i < ${#PLUGIN_DATASTORE_PORTS[@]}; i++)); do echo -n "-p ${PORTS[i]}:${PLUGIN_DATASTORE_PORTS[i]} " done } @@ -27,11 +28,11 @@ get_database_name() { get_random_ports() { declare desc="Retrieves N random ports" declare iterations="${1:-1}" - for (( i=0; i < iterations; i++ )); do + for ((i = 0; i < iterations; i++)); do local port=$RANDOM local quit=0 while [ "$quit" -ne 1 ]; do - netstat -an | grep $port > /dev/null + netstat -an | grep $port >/dev/null # shellcheck disable=SC2181 if [ $? -gt 0 ]; then quit=1 @@ -59,7 +60,7 @@ is_container_status() { declare desc="Returns 0 or 1 depending upon whether a given container has a certain status" declare CID="$1" STATUS="$2" local TEMPLATE="{{.State.$STATUS}}" - local CONTAINER_STATUS=$(docker inspect -f "$TEMPLATE" "$CID" 2> /dev/null || true) + local CONTAINER_STATUS=$(docker inspect -f "$TEMPLATE" "$CID" 2>/dev/null || true) if [[ "$CONTAINER_STATUS" == "true" ]]; then return 0 @@ -108,7 +109,7 @@ service_alternative_alias() { declare desc="Retrieves an alternative alias for a service" declare EXISTING_CONFIG="$1" local COLORS=(AQUA BLACK BLUE FUCHSIA GRAY GREEN LIME MAROON NAVY OLIVE PURPLE RED SILVER TEAL WHITE YELLOW) - local ALIAS; + local ALIAS for COLOR in "${COLORS[@]}"; do ALIAS="${PLUGIN_ALT_ALIAS}_${COLOR}" @@ -126,11 +127,11 @@ service_app_links() { declare APP="$1" local SERVICE LINKED_APP - pushd "$PLUGIN_DATA_ROOT" > /dev/null + pushd "$PLUGIN_DATA_ROOT" >/dev/null for SERVICE in *; do [[ -f "$SERVICE/LINKS" ]] || continue for LINKED_APP in $(<"$SERVICE/LINKS"); do - if [[ "$LINKED_APP" == "$APP" ]] ; then + if [[ "$LINKED_APP" == "$APP" ]]; then echo "$SERVICE" fi done @@ -159,10 +160,10 @@ service_backup() { TMPDIR=$(mktemp -d) trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT - docker inspect "$ID" &> /dev/null || dokku_log_fail "Service container does not exist" + docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist" is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running" - (service_export "$SERVICE" > "${TMPDIR}/export") + (service_export "$SERVICE" >"${TMPDIR}/export") # Build parameter list for s3backup tool BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e BUCKET_NAME=$BUCKET_NAME" @@ -195,19 +196,19 @@ service_backup_auth() { local SERVICE_BACKUP_ROOT="$PLUGIN_DATA_ROOT/$SERVICE/backup" mkdir "$SERVICE_BACKUP_ROOT" - echo "$AWS_ACCESS_KEY_ID" > "$SERVICE_BACKUP_ROOT/AWS_ACCESS_KEY_ID" - echo "$AWS_SECRET_ACCESS_KEY" > "$SERVICE_BACKUP_ROOT/AWS_SECRET_ACCESS_KEY" + echo "$AWS_ACCESS_KEY_ID" >"$SERVICE_BACKUP_ROOT/AWS_ACCESS_KEY_ID" + echo "$AWS_SECRET_ACCESS_KEY" >"$SERVICE_BACKUP_ROOT/AWS_SECRET_ACCESS_KEY" if [[ -n "$AWS_DEFAULT_REGION" ]]; then - echo "$AWS_DEFAULT_REGION" > "$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION" + echo "$AWS_DEFAULT_REGION" >"$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION" fi if [[ -n "$AWS_SIGNATURE_VERSION" ]]; then - echo "$AWS_SIGNATURE_VERSION" > "$SERVICE_BACKUP_ROOT/AWS_SIGNATURE_VERSION" + echo "$AWS_SIGNATURE_VERSION" >"$SERVICE_BACKUP_ROOT/AWS_SIGNATURE_VERSION" fi if [[ -n "$ENDPOINT_URL" ]]; then - echo "$ENDPOINT_URL" > "$SERVICE_BACKUP_ROOT/ENDPOINT_URL" + echo "$ENDPOINT_URL" >"$SERVICE_BACKUP_ROOT/ENDPOINT_URL" fi } @@ -231,7 +232,7 @@ service_backup_schedule() { dokku_log_fail "Invalid flag provided, only '--use-iam' allowed" fi - echo "${SCHEDULE} dokku ${DOKKU_BIN} ${PLUGIN_COMMAND_PREFIX}:backup ${SERVICE} ${BUCKET_NAME} ${USE_IAM_OPTIONAL_FLAG}" > "$TMP_CRON_FILE" + echo "${SCHEDULE} dokku ${DOKKU_BIN} ${PLUGIN_COMMAND_PREFIX}:backup ${SERVICE} ${BUCKET_NAME} ${USE_IAM_OPTIONAL_FLAG}" >"$TMP_CRON_FILE" sudo /bin/mv "$TMP_CRON_FILE" "$CRON_FILE" sudo /bin/chown root:root "$CRON_FILE" sudo /bin/chmod 644 "$CRON_FILE" @@ -264,7 +265,7 @@ service_backup_set_encryption() { local SERVICE_BACKUP_ENCRYPTION_ROOT="${SERVICE_ROOT}/backup-encryption/" mkdir "$SERVICE_BACKUP_ENCRYPTION_ROOT" - echo "$ENCRYPTION_KEY" > "${SERVICE_BACKUP_ENCRYPTION_ROOT}/ENCRYPTION_KEY" + echo "$ENCRYPTION_KEY" >"${SERVICE_BACKUP_ENCRYPTION_ROOT}/ENCRYPTION_KEY" } service_backup_unset_encryption() { @@ -290,8 +291,8 @@ service_container_rm() { fi 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 + 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 } @@ -302,7 +303,7 @@ service_enter() { local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" local ID="$(cat "$SERVICE_ROOT/ID")" - docker inspect "$ID" &> /dev/null || dokku_log_fail "Service container does not exist" + docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist" is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running" local EXEC_CMD="" @@ -318,7 +319,7 @@ service_exposed_ports() { local PORT_FILE="$SERVICE_ROOT/PORT" [[ ! -f $PORT_FILE ]] && echo '-' && return 0 local PORTS=($(cat "$PORT_FILE")) - for (( i=0; i < ${#PLUGIN_DATASTORE_PORTS[@]}; i++ )); do + for ((i = 0; i < ${#PLUGIN_DATASTORE_PORTS[@]}; i++)); do echo -n "${PLUGIN_DATASTORE_PORTS[i]}->${PORTS[i]} " done } @@ -327,7 +328,7 @@ 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 + if [[ "$(docker images -q "$IMAGE" 2>/dev/null)" == "" ]]; then return 1 fi @@ -415,10 +416,10 @@ service_link() { [[ -n $LINK ]] && dokku_log_fail "Already linked as $LINK" touch "$LINKS_FILE" - echo "$APP" >> "$LINKS_FILE" + echo "$APP" >>"$LINKS_FILE" sort "$LINKS_FILE" -u -o "$LINKS_FILE" - if declare -f -F add_passed_docker_option > /dev/null; then + if declare -f -F add_passed_docker_option >/dev/null; then # shellcheck disable=SC2034 local passed_phases=(build deploy run) add_passed_docker_option passed_phases[@] "--link $SERVICE_NAME:$SERVICE_DNS_HOSTNAME" @@ -436,14 +437,14 @@ service_linked_apps() { local LINKS_FILE="$SERVICE_ROOT/LINKS" touch "$LINKS_FILE" - [[ -z $(< "$LINKS_FILE") ]] && echo '-' && return 0 + [[ -z $(<"$LINKS_FILE") ]] && echo '-' && return 0 - tr '\n' ' ' < "$LINKS_FILE" + tr '\n' ' ' <"$LINKS_FILE" } service_list() { declare desc="Lists all services and their status" - local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2> /dev/null) + local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null) if [[ -z $SERVICES ]]; then dokku_log_warn "There are no $PLUGIN_SERVICE services" else @@ -471,7 +472,7 @@ service_logs() { DOKKU_LOGS_ARGS="--follow" fi - docker inspect "$ID" &> /dev/null || dokku_log_fail "Service container does not exist" + docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist" is_container_status "$ID" "Running" || dokku_log_warn "Service logs may not be output as service is not running" # shellcheck disable=SC2086 @@ -480,24 +481,26 @@ service_logs() { service_parse_args() { declare desc="cli arg parser" - local next_index=1; local skip=false; local args=("$@") + local next_index=1 + local skip=false + local args=("$@") for arg in "$@"; do shift case "$arg" in - "--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" + "--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 @@ -505,33 +508,45 @@ service_parse_args() { 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}" - ;; - c) export PLUGIN_CONFIG_OPTIONS=$OPTARG - ;; - C) export SERVICE_CUSTOM_ENV=$OPTARG - ;; - d) export SERVICE_DATABASE=$OPTARG - ;; - i) export PLUGIN_IMAGE=$OPTARG - ;; - I) export PLUGIN_IMAGE_VERSION=$OPTARG - ;; - m) export SERVICE_MEMORY=$OPTARG - ;; - p) export SERVICE_PASSWORD=$OPTARG - ;; - q) export SERVICE_QUERYSTRING=${OPTARG#"?"} - ;; - R) export SERVICE_RESTART_APPS=$OPTARG - ;; - r) export SERVICE_ROOT_PASSWORD=$OPTARG - ;; - u) export SERVICE_USER=$OPTARG - ;; + SERVICE_ALIAS="${OPTARG^^}" + export SERVICE_ALIAS="${SERVICE_ALIAS%_URL}" + ;; + c) + export PLUGIN_CONFIG_OPTIONS=$OPTARG + ;; + C) + export SERVICE_CUSTOM_ENV=$OPTARG + ;; + d) + export SERVICE_DATABASE=$OPTARG + ;; + i) + export PLUGIN_IMAGE=$OPTARG + ;; + I) + export PLUGIN_IMAGE_VERSION=$OPTARG + ;; + m) + export SERVICE_MEMORY=$OPTARG + ;; + p) + export SERVICE_PASSWORD=$OPTARG + ;; + q) + export SERVICE_QUERYSTRING=${OPTARG#"?"} + ;; + R) + export SERVICE_RESTART_APPS=$OPTARG + ;; + r) + export SERVICE_ROOT_PASSWORD=$OPTARG + ;; + u) + export SERVICE_USER=$OPTARG + ;; esac done - shift "$(( OPTIND - 1 ))" # remove options from positional parameters + shift "$((OPTIND - 1))" # remove options from positional parameters } service_port_expose() { @@ -564,8 +579,8 @@ service_port_pause() { return fi - docker stop "$EXPOSED_NAME" > /dev/null 2>&1 || true - docker rm "$EXPOSED_NAME" > /dev/null 2>&1 || true + docker stop "$EXPOSED_NAME" >/dev/null 2>&1 || true + docker rm "$EXPOSED_NAME" >/dev/null 2>&1 || true if [[ "$LOG_FAIL" == "true" ]]; then dokku_log_info1 "Service $SERVICE unexposed" fi @@ -602,10 +617,10 @@ service_port_unpause() { PORTS=($(cat "$PORT_FILE")) fi - echo "${PORTS[@]}" > "$PORT_FILE" + echo "${PORTS[@]}" >"$PORT_FILE" # shellcheck disable=SC2046 - docker run -d --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" --name "$EXPOSED_NAME" $(docker_ports_options "${PORTS[@]}") --restart always --label dokku=ambassador --label "dokku.ambassador=$PLUGIN_COMMAND_PREFIX" dokku/ambassador:0.2.0 > /dev/null + docker run -d --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" --name "$EXPOSED_NAME" $(docker_ports_options "${PORTS[@]}") --restart always --label dokku=ambassador --label "dokku.ambassador=$PLUGIN_COMMAND_PREFIX" dokku/ambassador:0.2.0 >/dev/null if [[ "$LOG_FAIL" == "true" ]]; then dokku_log_info1 "Service $SERVICE exposed on port(s) [container->host]: $(service_exposed_ports "$SERVICE")" fi @@ -646,7 +661,7 @@ service_set_alias() { local ALIAS_FILE="$SERVICE_ROOT/ALIAS" touch "$ALIAS_FILE" - echo "$ALIAS" > "$ALIAS_FILE" + echo "$ALIAS" >"$ALIAS_FILE" } service_status() { @@ -662,7 +677,7 @@ service_status() { is_container_status "$ID" "Restarting" && echo "restarting" && return 0 is_container_status "$ID" "Running" && echo "running" && return 0 - CONTAINER_STATUS=$(docker inspect -f "{{.State.Status}}" "$CID" 2> /dev/null || true) + CONTAINER_STATUS=$(docker inspect -f "{{.State.Status}}" "$CID" 2>/dev/null || true) [[ -n "$CONTAINER_STATUS" ]] && echo "$CONTAINER_STATUS" && return 0 echo "missing" && return 0 } @@ -670,14 +685,14 @@ service_status() { service_stop() { declare desc="Stops a running service" declare SERVICE="$1" - local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; + local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" local SERVICE_NAME="$(get_service_name "$SERVICE")" local ID=$(docker ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true [[ -z $ID ]] && dokku_log_warn "Service is already stopped" && return 0 if [[ -n $ID ]]; then dokku_log_info2_quiet "Stopping container" - docker stop "$SERVICE_NAME" > /dev/null + docker stop "$SERVICE_NAME" >/dev/null service_port_pause "$SERVICE" dokku_log_verbose_quiet "Container stopped" else @@ -697,7 +712,7 @@ service_unlink() { remove_from_links_file "$SERVICE" "$APP" - if declare -f -F add_passed_docker_option > /dev/null; then + if declare -f -F add_passed_docker_option >/dev/null; then # shellcheck disable=SC2034 local passed_phases=(build deploy run) remove_passed_docker_option passed_phases[@] "--link $SERVICE_NAME:$SERVICE_DNS_HOSTNAME" @@ -713,7 +728,7 @@ service_version() { declare desc="Displays the running version for an image" declare SERVICE="$1" local SERVICE_NAME="$(get_service_name "$SERVICE")" - docker inspect -f '{{.Config.Image}}' "$SERVICE_NAME" 2> /dev/null || true + docker inspect -f '{{.Config.Image}}' "$SERVICE_NAME" 2>/dev/null || true } update_plugin_scheme_for_app() { diff --git a/functions b/functions index 9e825cb..cefd73b 100755 --- a/functions +++ b/functions @@ -1,6 +1,7 @@ #!/usr/bin/env bash source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions" source "$PLUGIN_BASE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" @@ -24,7 +25,8 @@ service_create() { is_valid_service_name "$SERVICE" || dokku_log_fail "Please specify a valid name for the service. Valid characters are: [A-Za-z0-9_]+" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] || dokku_log_fail "$PLUGIN_SERVICE service $SERVICE already exists" - SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS" + SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" + LINKS_FILE="$SERVICE_ROOT/LINKS" service_parse_args "${@:2}" @@ -43,8 +45,8 @@ service_create() { mkdir -p "$SERVICE_ROOT/config" || dokku_log_fail "Unable to create service config directory" touch "$LINKS_FILE" - echo -e "[mysqld]\nperformance_schema = 0" > "$SERVICE_ROOT/config/disable_performance_schema.cnf" - echo -e "[mysqld]\ncharacter-set-server = utf8\ncollation-server = utf8_general_ci" > "$SERVICE_ROOT/config/charset_utf8.cnf" + echo -e "[mysqld]\nperformance_schema = 0" >"$SERVICE_ROOT/config/disable_performance_schema.cnf" + echo -e "[mysqld]\ncharacter-set-server = utf8\ncollation-server = utf8_general_ci" >"$SERVICE_ROOT/config/charset_utf8.cnf" ROOTPASSWORD=$(openssl rand -hex 8) PASSWORD=$(openssl rand -hex 8) if [[ -n "$SERVICE_PASSWORD" ]]; then @@ -55,15 +57,15 @@ service_create() { ROOTPASSWORD="$SERVICE_ROOT_PASSWORD" dokku_log_warn "Specified root password may not be as secure as the auto-generated root password" fi - echo "$ROOTPASSWORD" > "$SERVICE_ROOT/ROOTPASSWORD" - echo "$PASSWORD" > "$SERVICE_ROOT/PASSWORD" + echo "$ROOTPASSWORD" >"$SERVICE_ROOT/ROOTPASSWORD" + echo "$PASSWORD" >"$SERVICE_ROOT/PASSWORD" chmod 640 "$SERVICE_ROOT/ROOTPASSWORD" "$SERVICE_ROOT/PASSWORD" [[ -n "$SERVICE_CUSTOM_ENV" ]] && MYSQL_CUSTOM_ENV="$SERVICE_CUSTOM_ENV" if [[ -n $MYSQL_CUSTOM_ENV ]]; then - echo "$MYSQL_CUSTOM_ENV" | tr ';' "\n" > "$SERVICE_ROOT/ENV" + echo "$MYSQL_CUSTOM_ENV" | tr ';' "\n" >"$SERVICE_ROOT/ENV" else - echo "" > "$SERVICE_ROOT/ENV" + echo "" >"$SERVICE_ROOT/ENV" fi service_create_container "$SERVICE" } @@ -77,10 +79,10 @@ service_create_container() { local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_HOST_ROOT/data:/var/lib/mysql" -v "$SERVICE_HOST_ROOT/config:/etc/mysql/conf.d" -e "MYSQL_ROOT_PASSWORD=$ROOTPASSWORD" -e MYSQL_USER=mysql -e "MYSQL_PASSWORD=$PASSWORD" -e "MYSQL_DATABASE=$SERVICE" --env-file="$SERVICE_ROOT/ENV" -d --restart always --label dokku=service --label dokku.service=mysql "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION") - echo "$ID" > "$SERVICE_ROOT/ID" + echo "$ID" >"$SERVICE_ROOT/ID" dokku_log_verbose_quiet "Waiting for container to be ready" - docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" dokku/wait:0.3.0 -p "$PLUGIN_DATASTORE_WAIT_PORT" > /dev/null + docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" dokku/wait:0.3.0 -p "$PLUGIN_DATASTORE_WAIT_PORT" >/dev/null dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE" service_info "$SERVICE" @@ -131,7 +133,7 @@ service_start() { local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" if [[ -n $PREVIOUS_ID ]]; then - docker start "$PREVIOUS_ID" > /dev/null + docker start "$PREVIOUS_ID" >/dev/null service_port_unpause "$SERVICE" dokku_log_info2 "Container started" elif service_image_exists "$SERVICE" && [[ -n "$ROOTPASSWORD" ]] && [[ -n "$PASSWORD" ]]; then diff --git a/help-functions b/help-functions index b6b7b73..9827927 100755 --- a/help-functions +++ b/help-functions @@ -1,6 +1,7 @@ #!/usr/bin/env bash source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions" export SUBCOMMAND_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands" @@ -13,7 +14,7 @@ fn-help() { exit 0 fi - pushd "$SUBCOMMAND_ROOT" > /dev/null 2>&1 + pushd "$SUBCOMMAND_ROOT" >/dev/null 2>&1 for cmd in *; do if [[ "$CMD" == "${PLUGIN_COMMAND_PREFIX}:$cmd" ]]; then "$SUBCOMMAND_ROOT/$cmd" "$@" @@ -21,7 +22,7 @@ fn-help() { exit "$EXIT_CODE" fi done - popd > /dev/null 2>&1 + popd >/dev/null 2>&1 exit "$DOKKU_NOT_IMPLEMENTED_EXIT" } @@ -31,7 +32,7 @@ fn-help-all() { local CMD_OUTPUT BLUE BOLD FULL_OUTPUT NORMAL FULL_OUTPUT=true - if [[ "$CMD" = "$PLUGIN_COMMAND_PREFIX:help" ]] || [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX" ]] || [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX:default" ]] ; then + if [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX:help" ]] || [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX" ]] || [[ "$CMD" == "$PLUGIN_COMMAND_PREFIX:default" ]]; then BOLD="$(fn-help-fancy-tput bold)" NORMAL="$(fn-help-fancy-color "\033[m")" BLUE="$(fn-help-fancy-color "\033[0;34m")" @@ -58,7 +59,7 @@ fn-help-all() { elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then fn-help-contents else - cat< /dev/null 2>&1 + pushd "$SUBCOMMAND_ROOT" >/dev/null 2>&1 for cmd in *; do fn-help-contents-subcommand "$cmd" || true done @@ -81,7 +82,7 @@ fn-help-contents-subcommand() { trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT rm -rf "$UNCLEAN_FILE" "$CLEAN_FILE" - cat "$SUBCOMMAND_ROOT/$SUBCOMMAND" > "$UNCLEAN_FILE" + cat "$SUBCOMMAND_ROOT/$SUBCOMMAND" >"$UNCLEAN_FILE" fn-help-subcommand-sanitize "$UNCLEAN_FILE" "$CLEAN_FILE" if ! is_implemented_command "$SUBCOMMAND"; then @@ -142,7 +143,7 @@ fn-help-contents-subcommand() { fn-help-fancy-tput() { declare desc="A wrapper around tput" - if [[ -n "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then + if [[ -n "$DOKKU_NO_COLOR" ]] || [[ "$TERM" == "unknown" ]] || [[ "$TERM" == "dumb" ]]; then return fi @@ -152,7 +153,7 @@ fn-help-fancy-tput() { fn-help-fancy-color() { declare desc="A wrapper around colors" - if [[ -n "$DOKKU_NO_COLOR" ]] || [[ "$TERM" = "unknown" ]] || [[ "$TERM" == "dumb" ]]; then + if [[ -n "$DOKKU_NO_COLOR" ]] || [[ "$TERM" == "unknown" ]] || [[ "$TERM" == "dumb" ]]; then return fi @@ -162,7 +163,7 @@ fn-help-fancy-color() { fn-help-list-example() { # shellcheck disable=SC2034 declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content" - cat<> "$OUTGOING_FUNC_FILE" + echo "$p" >>"$OUTGOING_FUNC_FILE" continue fi if [[ "$p" == *"()"* ]]; then FUNCTION_FOUND=true - echo "$p" >> "$OUTGOING_FUNC_FILE" + echo "$p" >>"$OUTGOING_FUNC_FILE" continue fi - done < "$FUNC_FILE" + done <"$FUNC_FILE" } _fn-help-apply-shell-expansion() { diff --git a/install b/install index 5cd2d55..ba5ca99 100755 --- a/install +++ b/install @@ -1,6 +1,7 @@ #!/usr/bin/env bash source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x plugin-install() { pull-docker-image() { @@ -10,7 +11,7 @@ plugin-install() { echo " ! docker pull ${IMAGE}" 1>&2 return fi - if [[ "$(docker images -q "${IMAGE}" 2> /dev/null)" == "" ]]; then + if [[ "$(docker images -q "${IMAGE}" 2>/dev/null)" == "" ]]; then docker pull "${IMAGE}" fi } @@ -31,7 +32,7 @@ plugin-install() { _SUDOERS_FILE="/etc/sudoers.d/dokku-${PLUGIN_COMMAND_PREFIX}" touch "$_SUDOERS_FILE" - cat > "$_SUDOERS_FILE" <"$_SUDOERS_FILE" < /dev/null +pushd "$PLUGIN_DATA_ROOT" >/dev/null for SERVICE in *; do dokku_log_verbose_quiet "Unlinking from $SERVICE" remove_from_links_file "$(basename "$SERVICE")" "$APP" diff --git a/subcommands/app-links b/subcommands/app-links index f315b59..b6df3a1 100755 --- a/subcommands/app-links +++ b/subcommands/app-links @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-app-links-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:app-links playground #A app, app to run command against declare desc="list all $PLUGIN_SERVICE service links for a given app" - local cmd="$PLUGIN_COMMAND_PREFIX:app-links" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:app-links" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare APP="$1" APP=${APP:="$DOKKU_APP_NAME"} diff --git a/subcommands/backup b/subcommands/backup index a22b976..2a4044b 100755 --- a/subcommands/backup +++ b/subcommands/backup @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -11,7 +12,8 @@ service-backup-cmd() { #A service, service to run command against #A bucket-name, name of the s3 bucket to upload backups to declare desc="creates a backup of the $PLUGIN_SERVICE service to an existing s3 bucket" - local cmd="$PLUGIN_COMMAND_PREFIX:backup" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:backup" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" BUCKET_NAME="$2" USE_IAM_OPTIONAL_FLAG="$3" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/backup-auth b/subcommands/backup-auth index 5c528bb..e1eb81c 100755 --- a/subcommands/backup-auth +++ b/subcommands/backup-auth @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -20,7 +21,8 @@ service-backup-auth-cmd() { #A aws-signature-version, (optional) the AWS signature version to use when signing S3 requests #A endpoint-url, (optional) an aws endpoint to upload to declare desc="sets up authentication for backups on the $PLUGIN_SERVICE service" - local cmd="$PLUGIN_COMMAND_PREFIX:backup-auth" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:backup-auth" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" AWS_ACCESS_KEY_ID="$2" AWS_SECRET_ACCESS_KEY="$3" AWS_DEFAULT_REGION="$4" AWS_SIGNATURE_VERSION="$5" ENDPOINT_URL="$6" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/backup-deauth b/subcommands/backup-deauth index 9d01e9c..2089e89 100755 --- a/subcommands/backup-deauth +++ b/subcommands/backup-deauth @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-backup-deauth-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:backup-deauth lolipop #A service, service to run command against declare desc="removes backup authentication for the $PLUGIN_SERVICE service" - local cmd="$PLUGIN_COMMAND_PREFIX:backup-deauth" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:backup-deauth" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/backup-schedule b/subcommands/backup-schedule index 8802da7..e5b8fbc 100755 --- a/subcommands/backup-schedule +++ b/subcommands/backup-schedule @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -15,7 +16,8 @@ service-backup-schedule-cmd() { #A schedule, a cron schedule to run backups on #A bucket-name, name of the s3 bucket to upload backups to declare desc="schedules a backup of the $PLUGIN_SERVICE service" - local cmd="$PLUGIN_COMMAND_PREFIX:backup-schedule" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:backup-schedule" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" SCHEDULE="$2" BUCKET_NAME="$3" USE_IAM_OPTIONAL_FLAG="$4" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/backup-schedule-cat b/subcommands/backup-schedule-cat index 7607991..eff6304 100755 --- a/subcommands/backup-schedule-cat +++ b/subcommands/backup-schedule-cat @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-backup-schedule-cat-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:backup-schedule-cat lolipop #A service, service to run command against declare desc="cat the contents of the configured backup cronfile for the service" - local cmd="$PLUGIN_COMMAND_PREFIX:backup-schedule-cat" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:backup-schedule-cat" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/backup-set-encryption b/subcommands/backup-set-encryption index 0e18de0..bb6e8db 100755 --- a/subcommands/backup-set-encryption +++ b/subcommands/backup-set-encryption @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -10,7 +11,8 @@ service-backup-set-encryption-cmd() { #A service, service to run command against #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 + local cmd="$PLUGIN_COMMAND_PREFIX:backup-set-encryption" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" PASSPHRASE="$2" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/backup-unschedule b/subcommands/backup-unschedule index b305901..32cbcad 100755 --- a/subcommands/backup-unschedule +++ b/subcommands/backup-unschedule @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-backup-unschedule-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:backup-unschedule lolipop #A service, service to run command against declare desc="unschedules the backup of the $PLUGIN_SERVICE service" - local cmd="$PLUGIN_COMMAND_PREFIX:backup-unschedule" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:backup-unschedule" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/backup-unset-encryption b/subcommands/backup-unset-encryption index acd4b4c..bba18a2 100755 --- a/subcommands/backup-unset-encryption +++ b/subcommands/backup-unset-encryption @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-backup-unset-encryption-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:backup-unset-encryption lolipop #A service, service to run command against declare desc="unsets encryption for future backups of the $PLUGIN_SERVICE service" - local cmd="$PLUGIN_COMMAND_PREFIX:backup-unset-encryption" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:backup-unset-encryption" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/clone b/subcommands/clone index df7648f..744e28a 100755 --- a/subcommands/clone +++ b/subcommands/clone @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -15,7 +16,8 @@ service-clone-cmd() { #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 then copy data from into " - local cmd="$PLUGIN_COMMAND_PREFIX:clone" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:clone" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" NEW_SERVICE="$2" CLONE_FLAGS_LIST=("${@:3}") is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" @@ -27,15 +29,15 @@ service-clone-cmd() { local ID="$(cat "$SERVICE_ROOT/ID")" is_container_status "$ID" "Running" || dokku_log_fail "Service ${SERVICE} container is not running" - PLUGIN_IMAGE=$(service_version "$SERVICE" | grep -o "^.*:" | sed -r "s/://g") - PLUGIN_IMAGE_VERSION=$(service_version "$SERVICE" | grep -o ":.*$" | sed -r "s/://g") + PLUGIN_IMAGE=$(service_version "$SERVICE" | grep -o "^.*:" | sed -r "s/://g") + PLUGIN_IMAGE_VERSION=$(service_version "$SERVICE" | grep -o ":.*$" | sed -r "s/://g") service_parse_args "${@:3}" dokku_log_info2 "Cloning $SERVICE to $NEW_SERVICE @ $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" service_create "$NEW_SERVICE" "${@:3}" dokku_log_info1 "Copying data from $SERVICE to $NEW_SERVICE" - service_export "$SERVICE" | service_import "$NEW_SERVICE" > /dev/null 2>&1 || true + service_export "$SERVICE" | service_import "$NEW_SERVICE" >/dev/null 2>&1 || true dokku_log_info2 "Done" } diff --git a/subcommands/connect b/subcommands/connect index 0746db4..8173faf 100755 --- a/subcommands/connect +++ b/subcommands/connect @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-connect-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:connect lolipop #A service, service to run command against declare desc="connect to the service via the $PLUGIN_COMMAND_PREFIX connection tool" - local cmd="$PLUGIN_COMMAND_PREFIX:connect" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:connect" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/create b/subcommands/create index abc5d9e..6b7edac 100755 --- a/subcommands/create +++ b/subcommands/create @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -12,7 +13,7 @@ service-create-cmd() { #E export ${PLUGIN_DEFAULT_ALIAS}_IMAGE="${PLUGIN_IMAGE}" #E export ${PLUGIN_DEFAULT_ALIAS}_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}" #E dokku $PLUGIN_COMMAND_PREFIX:create lolipop - #E you can also specify custom environment variables to start + #E you can also specify custom environment variables to start #E the ${PLUGIN_COMMAND_PREFIX} service in semi-colon separated form. #E export ${PLUGIN_DEFAULT_ALIAS}_CUSTOM_ENV="USER=alpha;HOST=beta" #E dokku $PLUGIN_COMMAND_PREFIX:create lolipop @@ -23,7 +24,8 @@ service-create-cmd() { #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" - local cmd="$PLUGIN_COMMAND_PREFIX:create" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:create" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" CREATE_FLAGS_LIST=("${@:2}") service_create "$SERVICE" "${@:2}" diff --git a/subcommands/destroy b/subcommands/destroy index f942150..57afc65 100755 --- a/subcommands/destroy +++ b/subcommands/destroy @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -10,12 +11,14 @@ service-destroy-cmd() { #A service, service to run command against #F -f|--force, force destroy without asking for confirmation declare desc="delete the $PLUGIN_SERVICE service/data/container if there are no links left" - local cmd="$PLUGIN_COMMAND_PREFIX:destroy" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:destroy" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" FORCE_FLAG="$2" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" - SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS" + SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" + LINKS_FILE="$SERVICE_ROOT/LINKS" SERVICE_HOST_ROOT="$PLUGIN_DATA_HOST_ROOT/$SERVICE" SERVICE_NAME="$(get_service_name "$SERVICE")" diff --git a/subcommands/enter b/subcommands/enter index b0fda22..d706eec 100755 --- a/subcommands/enter +++ b/subcommands/enter @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -13,7 +14,8 @@ service-enter-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:enter lolipop touch /tmp/test #A service, service to run command against declare desc="enter or run a command in a running $PLUGIN_SERVICE service container" - local cmd="$PLUGIN_COMMAND_PREFIX:enter" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:enter" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" dokku_log_info1_quiet "Filesystem changes may not persist after container restarts" diff --git a/subcommands/exists b/subcommands/exists index 457aa27..d611b3d 100755 --- a/subcommands/exists +++ b/subcommands/exists @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-exists-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:exists lolipop #A service, service to run command against declare desc="check if the $PLUGIN_SERVICE service exists" - local cmd="$PLUGIN_COMMAND_PREFIX:exists" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:exists" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/export b/subcommands/export index d63e95b..651416c 100755 --- a/subcommands/export +++ b/subcommands/export @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -11,7 +12,8 @@ service-export-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:export lolipop > lolipop.dump #A service, service to run command against declare desc="export a dump of the $PLUGIN_SERVICE service database" - local cmd="$PLUGIN_COMMAND_PREFIX:export" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:export" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/expose b/subcommands/expose index 684359e..7bb88e7 100755 --- a/subcommands/expose +++ b/subcommands/expose @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -10,7 +11,8 @@ service-expose-cmd() { #A service, service to run command against #A ports, a list of ports to run against declare desc="expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)" - local cmd="$PLUGIN_COMMAND_PREFIX:expose" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:expose" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" PORTS_LIST=("${@:2}") [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/import b/subcommands/import index 1239c4f..9528b1d 100755 --- a/subcommands/import +++ b/subcommands/import @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-import-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:import lolipop < database.dump #A service, service to run command against declare desc="import a dump into the $PLUGIN_SERVICE service database" - local cmd="$PLUGIN_COMMAND_PREFIX:import" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:import" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" diff --git a/subcommands/info b/subcommands/info index d1dd6aa..21dfd4a 100755 --- a/subcommands/info +++ b/subcommands/info @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -30,7 +31,8 @@ service-info-cmd() { #F --status, show the service running status #F --version, show the service image version declare desc="print the connection information" - local cmd="$PLUGIN_COMMAND_PREFIX:info" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:info" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" INFO_FLAG="$2" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/link b/subcommands/link index 24d7ba3..851229e 100755 --- a/subcommands/link +++ b/subcommands/link @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -42,7 +43,8 @@ service-link-cmd() { #F -a|--alias "BLUE_DATABASE", an alternative alias to use for linking to an app via environment variable #F -q|--querystring "pool=5", ampersand delimited querystring arguments to append to the service link declare desc="link the $PLUGIN_SERVICE service to the app" - local cmd="$PLUGIN_COMMAND_PREFIX:link" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:link" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" APP="$2" LINK_FLAGS_LIST=("${@:3}") APP=${APP:="$DOKKU_APP_NAME"} diff --git a/subcommands/linked b/subcommands/linked index 1fd94ab..baf2970 100755 --- a/subcommands/linked +++ b/subcommands/linked @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -10,7 +11,8 @@ service-linked-cmd() { #A service, service to run command against #A app, app to run command against declare desc="check if the $PLUGIN_SERVICE service is linked to an app" - local cmd="$PLUGIN_COMMAND_PREFIX:linked" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:linked" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" APP="$2" APP=${APP:="$DOKKU_APP_NAME"} diff --git a/subcommands/list b/subcommands/list index 51722ae..cd4d52e 100755 --- a/subcommands/list +++ b/subcommands/list @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -8,7 +9,8 @@ service-list-cmd() { #E list all services #E dokku $PLUGIN_COMMAND_PREFIX:list declare desc="list all $PLUGIN_SERVICE services" - local cmd="$PLUGIN_COMMAND_PREFIX:list" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:list" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 service_list } diff --git a/subcommands/logs b/subcommands/logs index efa9f08..5f4ef8c 100755 --- a/subcommands/logs +++ b/subcommands/logs @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -12,7 +13,8 @@ service-logs-cmd() { #A service, service to run command against #F -t|--tail, do not stop when end of the logs are reached and wait for additional output declare desc="print the most recent log(s) for this service" - local cmd="$PLUGIN_COMMAND_PREFIX:logs" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:logs" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" TAIL_FLAG="$2" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/promote b/subcommands/promote index 06d0b37..eec7e02 100755 --- a/subcommands/promote +++ b/subcommands/promote @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -23,7 +24,8 @@ service-promote-cmd() { #A service, service to run command against #A app, app to run command against declare desc="promote service as ${PLUGIN_DEFAULT_ALIAS}_URL in " - local cmd="$PLUGIN_COMMAND_PREFIX:promote" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:promote" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" APP="$2" APP=${APP:="$DOKKU_APP_NAME"} diff --git a/subcommands/restart b/subcommands/restart index b6d5dae..8fbc9a3 100755 --- a/subcommands/restart +++ b/subcommands/restart @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-restart-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:restart lolipop #A service, service to run command against declare desc="graceful shutdown and restart of the $PLUGIN_SERVICE service container" - local cmd="$PLUGIN_COMMAND_PREFIX:restart" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:restart" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/start b/subcommands/start index 47fc913..7f58822 100755 --- a/subcommands/start +++ b/subcommands/start @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-start-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:start lolipop #A service, service to run command against declare desc="start a previously stopped $PLUGIN_SERVICE service" - local cmd="$PLUGIN_COMMAND_PREFIX:start" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:start" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/stop b/subcommands/stop index 59b98cc..7ccd0e2 100755 --- a/subcommands/stop +++ b/subcommands/stop @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-stop-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:stop lolipop #A service, service to run command against declare desc="stop a running $PLUGIN_SERVICE service" - local cmd="$PLUGIN_COMMAND_PREFIX:stop" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:stop" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/unexpose b/subcommands/unexpose index c821842..ae748f7 100755 --- a/subcommands/unexpose +++ b/subcommands/unexpose @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -9,7 +10,8 @@ service-unexpose-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:unexpose lolipop #A service, service to run command against declare desc="unexpose a previously exposed $PLUGIN_SERVICE service" - local cmd="$PLUGIN_COMMAND_PREFIX:unexpose" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:unexpose" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/subcommands/unlink b/subcommands/unlink index 487ecc1..0c9729a 100755 --- a/subcommands/unlink +++ b/subcommands/unlink @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" @@ -11,7 +12,8 @@ service-unlink-cmd() { #A service, service to run command against #A app, app to run command against declare desc="unlink the $PLUGIN_SERVICE service from the app" - local cmd="$PLUGIN_COMMAND_PREFIX:unlink" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 + local cmd="$PLUGIN_COMMAND_PREFIX:unlink" argv=("$@") + [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" APP="$2" APP=${APP:="$DOKKU_APP_NAME"} diff --git a/subcommands/upgrade b/subcommands/upgrade index 1234003..cd05888 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -1,6 +1,7 @@ #!/usr/bin/env bash 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 "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" @@ -14,7 +15,8 @@ service-upgrade-cmd() { #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 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" UPGRADE_FLAGS_LIST=("${@:2}") [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" diff --git a/tests/setup.sh b/tests/setup.sh index e88fb46..6005ecb 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -set -eo pipefail; [[ $TRACE ]] && set -x +set -eo pipefail +[[ $TRACE ]] && set -x wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh if [[ "$DOKKU_VERSION" == "master" ]]; then sudo bash bootstrap.sh diff --git a/tests/test_helper.bash b/tests/test_helper.bash index a70310d..8a0d1ee 100755 --- a/tests/test_helper.bash +++ b/tests/test_helper.bash @@ -3,8 +3,11 @@ export DOKKU_LIB_ROOT="/var/lib/dokku" source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" flunk() { - { if [ "$#" -eq 0 ]; then cat - - else echo "$*" + { + if [ "$#" -eq 0 ]; then + cat - + else + echo "$*" fi } return 1 @@ -12,7 +15,8 @@ flunk() { assert_equal() { if [ "$1" != "$2" ]; then - { echo "expected: $1" + { + echo "expected: $1" echo "actual: $2" } | flunk fi @@ -59,8 +63,10 @@ assert_contains() { # shellcheck disable=SC2154 assert_output() { local expected - if [ $# -eq 0 ]; then expected="$(cat -)" - else expected="$1" + if [ $# -eq 0 ]; then + expected="$(cat -)" + else + expected="$1" fi assert_equal "$expected" "$output" }