From 8e8b6d60f093fea74a348aa4070349eb352c6fa2 Mon Sep 17 00:00:00 2001 From: Alex Quick Date: Wed, 19 Jul 2017 09:45:58 -0400 Subject: [PATCH] fix: Declare and assign separately to avoid masking return values. --- plugins/00_dokku-standard/exec-app-json-scripts | 8 +++++--- plugins/build-env/pre-build-buildpack | 9 ++++++--- plugins/common/functions | 9 +++++---- plugins/config/glide.yaml | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/plugins/00_dokku-standard/exec-app-json-scripts b/plugins/00_dokku-standard/exec-app-json-scripts index 8077e7a65..172dfdf99 100755 --- a/plugins/00_dokku-standard/exec-app-json-scripts +++ b/plugins/00_dokku-standard/exec-app-json-scripts @@ -23,8 +23,10 @@ get_phase_script() { execute_script() { declare desc="executes appropriate phase script key from app.json" - local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG") - local PHASE_SCRIPT_KEY="$3" + local APP="$1"; local IMAGE_TAG="$2"; local PHASE_SCRIPT_KEY="$3" + local IMAGE id + + IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG") local SCRIPT_CMD=$(get_phase_script "$IMAGE" "$PHASE_SCRIPT_KEY" 2>/dev/null) if [[ -n "$SCRIPT_CMD" ]];then dokku_log_info1 "Running '$SCRIPT_CMD' in app container" @@ -59,7 +61,7 @@ execute_script() { declare -a ARG_ARRAY eval "ARG_ARRAY=($DOCKER_ARGS)" - local id=$(docker run "$DOKKU_GLOBAL_RUN_ARGS" -e DOKKU_TRACE="$DOKKU_TRACE" --label=dokku_phase_script="${PHASE_SCRIPT_KEY}" -d -v "$CACHE_DIR:/cache" "${ARG_ARRAY[@]}" "$IMAGE" /bin/bash -c "$COMMAND") + id=$(docker run "$DOKKU_GLOBAL_RUN_ARGS" -e DOKKU_TRACE="$DOKKU_TRACE" --label=dokku_phase_script="${PHASE_SCRIPT_KEY}" -d -v "$CACHE_DIR:/cache" "${ARG_ARRAY[@]}" "$IMAGE" /bin/bash -c "$COMMAND") if test "$(docker wait "$id")" -eq 0; then dokku_container_log_verbose_quiet "$id" if [[ "$PHASE_SCRIPT_KEY" != "postdeploy" ]];then diff --git a/plugins/build-env/pre-build-buildpack b/plugins/build-env/pre-build-buildpack index 4a6e980c1..c874eca53 100755 --- a/plugins/build-env/pre-build-buildpack +++ b/plugins/build-env/pre-build-buildpack @@ -6,8 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" build_env_pre_build_buildpack() { declare desc="build-env pre-build-buildpack plugin trigger" local trigger="build_env_pre_build_buildpack" - local APP="$1"; local IMAGE=$(get_app_image_name "$APP"); + local APP="$1" + local IMAGE id + verify_app_name "$APP" + IMAGE=$(get_app_image_name "$APP"); [[ -z $(config_get --global CURL_CONNECT_TIMEOUT) ]] && config_set --global CURL_CONNECT_TIMEOUT=90 [[ -z $(config_get --global CURL_TIMEOUT) ]] && config_set --global CURL_TIMEOUT=60 @@ -15,12 +18,12 @@ build_env_pre_build_buildpack() { dokku_log_info1 "Adding BUILD_ENV to build environment..." # create build env files for use in buildpacks like this: # https://github.com/niteoweb/heroku-buildpack-buildout/blob/5879fa3418f7d8e079f1aa5816ba1adde73f4948/bin/compile#L34 - local id=$(config_bundle --merged "$APP" | docker run "$DOKKU_GLOBAL_RUN_ARGS" -i -a stdin "$IMAGE" /bin/bash -c "mkdir -p /tmp/env; cat | tar -x -C /tmp/env") + id=$(config_bundle --merged "$APP" | docker run "$DOKKU_GLOBAL_RUN_ARGS" -i -a stdin "$IMAGE" /bin/bash -c "mkdir -p /tmp/env; cat | tar -x -C /tmp/env") test "$(docker wait "$id")" -eq 0 docker commit "$id" "$IMAGE" > /dev/null # create build env for 'old style' buildpacks and dokku plugins - local id=$(config_export app "$APP" --format envfile --merged | docker run "$DOKKU_GLOBAL_RUN_ARGS" -i -a stdin "$IMAGE" /bin/bash -c "cat >> /app/.env") + id=$(config_export app "$APP" --format envfile --merged | docker run "$DOKKU_GLOBAL_RUN_ARGS" -i -a stdin "$IMAGE" /bin/bash -c "cat >> /app/.env") test "$(docker wait "$id")" -eq 0 docker commit "$id" "$IMAGE" > /dev/null } diff --git a/plugins/common/functions b/plugins/common/functions index 1db8dba99..8be21e1a8 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -440,6 +440,7 @@ dokku_build() { source "$PLUGIN_AVAILABLE_PATH/config/functions" local APP="$1"; local IMAGE_SOURCE_TYPE="$2"; local TMP_WORK_DIR="$3"; local IMAGE=$(get_app_image_name "$APP") + local id verify_app_name "$APP" local CACHE_DIR="$DOKKU_ROOT/$APP/cache" @@ -461,7 +462,7 @@ dokku_build() { declare -a ARG_ARRAY eval "ARG_ARRAY=($DOCKER_ARGS)" # shellcheck disable=SC2086 - local id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d -v $CACHE_DIR:/cache -e CACHE_PATH=/cache "${ARG_ARRAY[@]}" $IMAGE /build) + id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d -v $CACHE_DIR:/cache -e CACHE_PATH=/cache "${ARG_ARRAY[@]}" $IMAGE /build) docker attach "$id" test "$(docker wait "$id")" -eq 0 docker commit "$id" "$IMAGE" > /dev/null @@ -616,7 +617,7 @@ dokku_deploy_cmd() { fi if [[ "$DOKKU_IS_APP_PROXY_ENABLED" == "true" ]]; then # shellcheck disable=SC2086 - local id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d -e PORT=$port "${ARG_ARRAY[@]}" $IMAGE $START_CMD) + id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d -e PORT=$port "${ARG_ARRAY[@]}" $IMAGE $START_CMD) local ipaddr=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$id") # Docker < 1.9 compatibility if [[ -z $ipaddr ]]; then @@ -624,13 +625,13 @@ dokku_deploy_cmd() { fi else # shellcheck disable=SC2086 - local id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d $DOKKU_DOCKER_PORT_ARGS -e PORT=$port "${ARG_ARRAY[@]}" $IMAGE $START_CMD) + id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d $DOKKU_DOCKER_PORT_ARGS -e PORT=$port "${ARG_ARRAY[@]}" $IMAGE $START_CMD) local port=$(docker port "$id" "$port" | sed 's/[0-9.]*://') local ipaddr=127.0.0.1 fi else # shellcheck disable=SC2086 - local id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d "${ARG_ARRAY[@]}" $IMAGE $START_CMD) + id=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d "${ARG_ARRAY[@]}" $IMAGE $START_CMD) fi kill_new() { diff --git a/plugins/config/glide.yaml b/plugins/config/glide.yaml index 5e318bb53..62e21eae6 100644 --- a/plugins/config/glide.yaml +++ b/plugins/config/glide.yaml @@ -2,4 +2,4 @@ package: . import: - package: github.com/ryanuber/columnize - package: github.com/alexquick/godotenv - version: feature-write-dotenv + version: master