diff --git a/plugins/apps/functions b/plugins/apps/functions index 97eafdd00..1bfbf49a2 100755 --- a/plugins/apps/functions +++ b/plugins/apps/functions @@ -11,7 +11,7 @@ apps_create() { [[ -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "Name is already taken" mkdir -p "$DOKKU_ROOT/$APP" - echo "Creating $APP... done" + dokku_log_info1_quiet "Creating $APP... done" plugn trigger post-create "$APP" } @@ -58,3 +58,18 @@ apps_exists() { [[ -d "$DOKKU_ROOT/$APP" ]] || dokku_log_fail "App does not exist" dokku_log_info1 "App already exists" } + +apps_maybe_create() { + declare desc="creates an app dir if allowed" + declare APP="$1" + + if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then + DOKKU_GLOBAL_DISABLE_AUTOCREATE="$(config_get --global DOKKU_DISABLE_APP_AUTOCREATION || true)" + if [[ "$DOKKU_GLOBAL_DISABLE_AUTOCREATE" == "true" ]]; then + dokku_log_warn "App auto-creation disabled." + dokku_log_fail " ! Re-enable app auto-creation or create an app with 'dokku apps:create ${APP}'" + else + suppress_output apps_create "$APP" + fi + fi +} \ No newline at end of file diff --git a/plugins/common/functions b/plugins/common/functions index 82f82f077..f1ba349d9 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -1186,3 +1186,17 @@ release_app_deploy_lock() { flock -u "$APP_DEPLOY_LOCK_FD" && rm -f "$APP_DEPLOY_LOCK_FILE" &> /dev/null } + +suppress_output() { + declare desc="suppress all output from a given command unless there is an error" + local TMP_COMMAND_OUTPUT + TMP_COMMAND_OUTPUT=$(mktemp "/tmp/${FUNCNAME[0]}.XXXX") + trap 'rm -rf "$TMP_COMMAND_OUTPUT" > /dev/null' RETURN INT TERM EXIT + + "$@" > "$TMP_COMMAND_OUTPUT" 2>&1 || { + local exit_code="$?" + cat "$TMP_COMMAND_OUTPUT" + return "$exit_code" + } + return 0 +} \ No newline at end of file diff --git a/plugins/git/functions b/plugins/git/functions index 5c2c09d46..e1189448e 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -36,15 +36,7 @@ git_build_app_repo() { chmod 755 "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" unset GIT_DIR GIT_WORK_TREE - DOKKU_GLOBAL_DISABLE_AUTOCREATE="$(config_get --global DOKKU_DISABLE_APP_AUTOCREATION || true)" - if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then - if [[ "$DOKKU_GLOBAL_DISABLE_AUTOCREATE" == "true" ]]; then - dokku_log_warn "Invalid app name '$APP' specified." - dokku_log_fail "Check the name of the app or create an app with 'dokku apps:create ${APP}'" - else - apps_create "$APP" - fi - fi + [[ ! -d "$DOKKU_ROOT/$APP" ]] && apps_maybe_create "$APP" if use_git_worktree; then # git worktree - this method uses git worktree which was introduced in git 2.5 @@ -107,20 +99,6 @@ git_trigger_build() { fi } -suppress_output() { - declare desc="suppress all output from a given command unless there is an error" - local TMP_COMMAND_OUTPUT - TMP_COMMAND_OUTPUT=$(mktemp "/tmp/${FUNCNAME[0]}.XXXX") - trap 'rm -rf "$TMP_COMMAND_OUTPUT" > /dev/null' RETURN INT TERM EXIT - - "$@" > "$TMP_COMMAND_OUTPUT" 2>&1 || { - local exit_code="$?" - cat "$TMP_COMMAND_OUTPUT" - return "$exit_code" - } - return 0 -} - git_deploy_branch() { declare desc="retrieve the deploy branch for a given application" local cmd="git-hook" @@ -207,6 +185,8 @@ git_upload_pack_cmd() { declare APP="$2" APP="$(echo "$APP" | perl -pe 's/(? /dev/null local PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" cat > "$PRERECEIVE_HOOK" <