Merge pull request #3852 from dokku/standardize-plugin-code

Standardize plugin code
This commit is contained in:
Jose Diaz-Gonzalez
2020-02-10 04:44:16 -05:00
committed by GitHub
265 changed files with 2122 additions and 1488 deletions

View File

@@ -17,7 +17,7 @@ build-in-docker: clean
bash -c "GO_ARGS='$(GO_ARGS)' make -j4 build" || exit $$?
clean:
rm -rf commands subcommands triggers
rm -rf commands subcommands triggers prop
find . -xtype l -delete
commands: **/**/commands.go

View File

@@ -233,10 +233,10 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
hello_main_cmd() {
cmd-hello-default() {
declare desc="prints Hello \$APP"
declare cmd="hello" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="hello"
[[ "$1" == "$cmd" ]] && shift 1
# Support --app/$DOKKU_APP_NAME flag
# Use the following lines to reorder args into "$cmd $DOKKU_APP_NAME $@""
[[ -n $DOKKU_APP_NAME ]] && set -- $DOKKU_APP_NAME $@
@@ -250,7 +250,7 @@ hello_main_cmd() {
echo "Hello $APP"
}
hello_main_cmd "$@"
cmd-hello-default "$@"
```
`hello/subcommands/world`
@@ -261,15 +261,15 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
hello_world_cmd() {
cmd-hello-world() {
declare desc="prints Hello world"
declare cmd="hello:world" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="hello:world"
[[ "$1" == "$cmd" ]] && shift 1
echo "Hello world"
}
hello_world_cmd "$@"
cmd-hello-world "$@"
```
`hello/commands`

5
dokku
View File

@@ -136,10 +136,7 @@ execute_dokku_cmd() {
nginx | nginx:*)
local PLUGIN_NAME=${PLUGIN_NAME/nginx/nginx-vhosts}
;;
deploy | delete | ls | run | cleanup)
local PLUGIN_NAME="00_dokku-standard"
;;
url | urls | report)
deploy | run | cleanup | url | urls | report)
local PLUGIN_NAME="00_dokku-standard"
;;
esac

View File

@@ -1,28 +1,12 @@
#!/usr/bin/env bash
[[ " help help:help cleanup:help run:help trace:help url:help urls:help version:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
[[ " help help:help cleanup:help run:help url:help urls:help version:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/00_dokku-standard/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | cleanup:help | run:help | trace:help | url:help | urls:help | version:help)
[[ $(echo "$1" | sed '/.*:help/!d') ]] && help_topic="${1%\:help}"
help_content_func() {
declare desc="return standard plugin help content"
cat <<help_content
cleanup [<app>], Cleans up exited/dead Docker containers and removes dangling images
run [--env KEY=VALUE] <app> <cmd>, Run a command in a new container using the current application image
url <app>, Show the first URL for an application (compatibility)
urls <app>, Show all URLs for an application
version , Print dokku's version
help , Print the list of commands
help_content
}
if [[ $help_topic ]]; then
help_content_func | sed "/^\s*$help_topic\s/!d" | sort | sed '/^.*:/d' | column -c2 -t -s,
else
help_content_func
fi
help | cleanup:help | run:help | url:help | urls:help | version:help)
cmd-standard-help "$@"
;;
*)

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-standard-help() {
declare desc="help command"
declare CMD="$1"
[[ $(echo "$CMD" | sed '/.*:help/!d') ]] && help_topic="${CMD%\:help}"
if [[ $help_topic ]]; then
fn-help-content | sed "/^\s*$help_topic\s/!d" | sort | sed '/^.*:/d' | column -c2 -t -s,
else
fn-help-content
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
cleanup [<app>], Cleans up exited/dead Docker containers and removes dangling images
run [--env KEY=VALUE] <app> <cmd>, Run a command in a new container using the current application image
url <app>, Show the first URL for an application (compatibility)
urls <app>, Show all URLs for an application
version , Print dokku's version
help , Print the list of commands
help_content
}

View File

@@ -3,7 +3,7 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
dokku_cleanup_cmd() {
cmd-cleanup() {
declare desc="cleans up old deployment cruft"
declare cmd="cleanup"
[[ "$1" == "$cmd" ]] && shift 1
@@ -16,4 +16,4 @@ dokku_cleanup_cmd() {
docker_cleanup "$APP" "true"
}
dokku_cleanup_cmd "$@"
cmd-cleanup "$@"

View File

@@ -4,4 +4,4 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
shift 1
dokku_deploy_cmd "$@"
cmd-deploy "$@"

View File

@@ -3,10 +3,11 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
dokku_report_cmd() {
cmd-report() {
declare desc="reports dokku vitals for troubleshooting"
local cmd="report"
declare APP="$2"
declare cmd="report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
dokku_log_info1 "uname: $(uname -a)"
dokku_log_info1 "memory: "
@@ -31,4 +32,4 @@ dokku_report_cmd() {
fi
}
dokku_report_cmd "$@"
cmd-report "$@"

View File

@@ -2,12 +2,12 @@
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
dokku_run_cmd() {
cmd-run() {
declare desc="runs command in container based on app image"
declare cmd="run" APP=""
shift
declare cmd="run"
[[ "$1" == "$cmd" ]] && shift 1
declare APP=""
declare -a RUN_ENV
RUN_ENV=()
@@ -40,4 +40,4 @@ dokku_run_cmd() {
plugn trigger scheduler-run "$DOKKU_SCHEDULER" "$APP" "${#RUN_ENV[@]}" "${RUN_ENV[@]}" "$@"
}
dokku_run_cmd "$@"
cmd-run "$@"

View File

@@ -3,11 +3,14 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
dokku_urls_cmd() {
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
local APP="$2"
cmd-urls() {
declare desc="reports dokku vitals for troubleshooting"
declare cmd="url"
declare APP="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
get_app_urls "$@"
}
dokku_urls_cmd "$@"
cmd-urls "$@"

View File

@@ -1,30 +1,12 @@
#!/usr/bin/env bash
[[ " help events:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/20_events/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | events:help)
help_content_func() {
declare desc="return events plugin help content"
cat <<help_content
events [-t], Show the last events (-t follows)
events:list, List logged events
events:on, Enable events logger
events:off, Disable events logger
help_content
}
if [[ $1 == "events:help" ]]; then
echo 'Usage: dokku events:COMMAND [-t]'
echo ''
echo 'Interact with Dokku event logger.'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
else
help_content_func
fi
cmd-events-help "$@"
;;
*)

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-events-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="events"
local plugin_description="Manage event logging"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
events [-t], Show the last events (-t follows)
events:list, List logged events
events:on, Enable events logger
events:off, Disable events logger
help_content
}

View File

@@ -3,55 +3,58 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
DOKKU_RSYSLOG_FILTER_DIR=/etc/rsyslog.d
DOKKU_RSYSLOG_FILTER=$DOKKU_RSYSLOG_FILTER_DIR/99-dokku.conf
DOKKU_LOGROTATE_FILE=/etc/logrotate.d/dokku
trigger-events-install() {
declare desc="20_events install plugin trigger"
declare trigger="install"
DOKKU_RSYSLOG_FILTER_DIR=/etc/rsyslog.d
DOKKU_RSYSLOG_FILTER=$DOKKU_RSYSLOG_FILTER_DIR/99-dokku.conf
DOKKU_LOGROTATE_FILE=/etc/logrotate.d/dokku
flag_rsyslog_needs_restart=n
flag_rsyslog_needs_restart=n
# This can be done unconditionally as mkdir -p
# exits gracefully if the path already exists
# shellcheck disable=SC2174
mkdir -m 775 -p "$DOKKU_LOGS_DIR"
case "$DOKKU_DISTRO" in
arch | debian | centos | rhel)
chgrp dokku "$DOKKU_LOGS_DIR"
;;
*)
chown syslog:dokku "$DOKKU_LOGS_DIR"
;;
esac
if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then
touch "$DOKKU_EVENTS_LOGFILE"
# This can be done unconditionally as mkdir -p
# exits gracefully if the path already exists
# shellcheck disable=SC2174
mkdir -m 775 -p "$DOKKU_LOGS_DIR"
case "$DOKKU_DISTRO" in
arch | debian | centos | rhel)
chgrp dokku "$DOKKU_EVENTS_LOGFILE"
chgrp dokku "$DOKKU_LOGS_DIR"
;;
*)
# chown syslog:root might not work on SUSE
chown syslog:dokku "$DOKKU_EVENTS_LOGFILE"
chown syslog:dokku "$DOKKU_LOGS_DIR"
;;
esac
chmod 664 "$DOKKU_EVENTS_LOGFILE"
fi
if [[ -d "$DOKKU_RSYSLOG_FILTER_DIR" && ! -f "$DOKKU_RSYSLOG_FILTER" ]]; then
cat >"$DOKKU_RSYSLOG_FILTER" <<EOF
if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then
touch "$DOKKU_EVENTS_LOGFILE"
case "$DOKKU_DISTRO" in
arch | debian | centos | rhel)
chgrp dokku "$DOKKU_EVENTS_LOGFILE"
;;
*)
# chown syslog:root might not work on SUSE
chown syslog:dokku "$DOKKU_EVENTS_LOGFILE"
;;
esac
chmod 664 "$DOKKU_EVENTS_LOGFILE"
fi
if [[ -d "$DOKKU_RSYSLOG_FILTER_DIR" && ! -f "$DOKKU_RSYSLOG_FILTER" ]]; then
cat >"$DOKKU_RSYSLOG_FILTER" <<EOF
:syslogtag, contains, "dokku-event" $DOKKU_EVENTS_LOGFILE
EOF
flag_rsyslog_needs_restart=y
fi
flag_rsyslog_needs_restart=y
fi
if [[ -f "$DOKKU_RSYSLOG_FILTER" ]] && ! grep -q "dokku-event" "$DOKKU_RSYSLOG_FILTER"; then
cat >"$DOKKU_RSYSLOG_FILTER" <<EOF
if [[ -f "$DOKKU_RSYSLOG_FILTER" ]] && ! grep -q "dokku-event" "$DOKKU_RSYSLOG_FILTER"; then
cat >"$DOKKU_RSYSLOG_FILTER" <<EOF
:syslogtag, contains, "dokku-event" $DOKKU_EVENTS_LOGFILE
EOF
flag_rsyslog_needs_restart=y
fi
flag_rsyslog_needs_restart=y
fi
if [[ ! -f "$DOKKU_LOGROTATE_FILE" ]]; then
cat >"$DOKKU_LOGROTATE_FILE" <<EOF
if [[ ! -f "$DOKKU_LOGROTATE_FILE" ]]; then
cat >"$DOKKU_LOGROTATE_FILE" <<EOF
$DOKKU_LOGS_DIR/*.log {
daily
rotate 7
@@ -67,17 +70,20 @@ $DOKKU_LOGS_DIR/*.log {
}
EOF
if [[ "$DOKKU_DISTRO" == "debian" ]]; then
sed -i 's/ syslog dokku$/ root dokku/g' $DOKKU_LOGROTATE_FILE
if [[ "$DOKKU_DISTRO" == "debian" ]]; then
sed -i 's/ syslog dokku$/ root dokku/g' $DOKKU_LOGROTATE_FILE
fi
flag_rsyslog_needs_restart=y
fi
flag_rsyslog_needs_restart=y
fi
if [[ -f "$DOKKU_RSYSLOG_FILTER" && "$flag_rsyslog_needs_restart" == "y" ]]; then
service rsyslog restart
fi
if [[ -f "$DOKKU_RSYSLOG_FILTER" && "$flag_rsyslog_needs_restart" == "y" ]]; then
service rsyslog restart
fi
[[ ! "$DOKKU_EVENTS" ]] || dokku_log_plugn_trigger_call "$(basename "$0")" "$@"
[[ ! "$DOKKU_EVENTS" ]] || dokku_log_plugn_trigger_call "$(basename "$0")" "$@"
exit 0
}
exit 0
trigger-events-install "$@"

View File

@@ -3,11 +3,14 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
events_main_cmd() {
cmd-events-default() {
declare desc="shows contents of dokku events log"
local cmd="events"
declare cmd="events"
[[ "$1" == "$cmd" ]] && shift 1
declare TAIL="$1"
if [[ -f $DOKKU_EVENTS_LOGFILE ]]; then
if [[ $2 == "-t" ]]; then
if [[ "$TAIL" == "-t" ]]; then
tail -F "$DOKKU_EVENTS_LOGFILE"
else
tail -n 100 "$DOKKU_EVENTS_LOGFILE"
@@ -15,4 +18,4 @@ events_main_cmd() {
fi
}
events_main_cmd "$@"
cmd-events-default "$@"

View File

@@ -3,9 +3,11 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
events_list_cmd() {
cmd-events-list() {
declare desc="lists enabled events"
local cmd="events:list"
declare cmd="events:list"
[[ "$1" == "$cmd" ]] && shift 1
local PLUGIN_DIR="$(dirname "$0")/.."
local logged hook
@@ -14,6 +16,9 @@ events_list_cmd() {
dokku_col_log_info2_quiet "Events currently logged"
for hook in $logged; do
if [[ "$hook" == "help-functions" ]]; then
continue
fi
dokku_col_log_msg "$hook"
done
else
@@ -21,4 +26,4 @@ events_list_cmd() {
fi
}
events_list_cmd "$@"
cmd-events-list "$@"

View File

@@ -3,11 +3,13 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
events_off_cmd() {
cmd-events-off() {
declare desc="disables dokku events logger"
local cmd="events:off"
declare cmd="events:off"
[[ "$1" == "$cmd" ]] && shift 1
echo "Disabling dokku events logger"
rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS"
}
events_off_cmd "$@"
cmd-events-off "$@"

View File

@@ -3,12 +3,14 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
events_on_cmd() {
cmd-events-on() {
declare desc="enables dokku events logger"
local cmd="events:on"
declare cmd="events:on"
[[ "$1" == "$cmd" ]] && shift 1
echo "Enabling dokku events logger"
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc"
echo "export DOKKU_EVENTS=1" >"$DOKKU_ROOT/.dokkurc/DOKKU_EVENTS"
}
events_on_cmd "$@"
cmd-events-on "$@"

View File

@@ -4,14 +4,13 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/app-json/internal-functions"
app_json_post_deploy() {
trigger-app-json-post-deploy() {
declare desc="app-json scripts execution"
local trigger="app_json_post_deploy"
local APP="$1"
local IMAGE_TAG="$4"
declare trigger="post-deploy"
declare APP="$1" IMAGE_TAG="$4"
local PHASE_SCRIPT_KEY="postdeploy"
execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY"
}
app_json_post_deploy "$@"
trigger-app-json-post-deploy "$@"

View File

@@ -4,15 +4,14 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/app-json/internal-functions"
app_json_pre_deploy() {
trigger-app-json-pre-deploy() {
declare desc="app-json scripts execution"
local trigger="app_json_pre_deploy"
local APP="$1"
local IMAGE_TAG="$2"
declare trigger="pre-deploy"
declare APP="$1" IMAGE_TAG="$2"
local PHASE_SCRIPT_KEY="predeploy"
execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY"
execute_script "$APP" "$IMAGE_TAG" "release"
}
app_json_pre_deploy "$@"
trigger-app-json-pre-deploy "$@"

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env bash
[[ " help apps:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
source "$PLUGIN_AVAILABLE_PATH/apps/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | apps:help)
apps_help_cmd "$@"
cmd-apps-help "$@"
;;
*)

42
plugins/apps/help-functions Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-apps-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="apps"
local plugin_description="Manage apps"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
apps, [DEPRECATED] Alias for apps:list
apps:clone <old-app> <new-app>, Clones an app
apps:create <app>, Create a new app
apps:destroy <app>, Permanently destroy an app
apps:exists <app>, Checks if an app exists
apps:list, List your apps
apps:lock <app>, Locks an app for deployment
apps:locked <app>, Checks if an app is locked for deployment
apps:rename <old-app> <new-app>, Rename an app
apps:report [<app>] [<flag>], Display report about an app
apps:unlock <app>, Unlocks an app for deployment
help_content
}

View File

@@ -6,9 +6,10 @@ set -eo pipefail
cmd-apps-report() {
declare desc="displays the app report for one or more apps"
local cmd="apps:report"
declare cmd="apps:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
@@ -78,50 +79,10 @@ cmd-apps-report-single() {
fi
}
apps_help_content_func() {
declare desc="return apps plugin help content"
cat <<help_content
apps, [DEPRECATED] Alias for apps:list
apps:clone <old-app> <new-app>, Clones an app
apps:create <app>, Create a new app
apps:destroy <app>, Permanently destroy an app
apps:exists <app>, Checks if an app exists
apps:list, List your apps
apps:lock <app>, Locks an app for deployment
apps:locked <app>, Checks if an app is locked for deployment
apps:rename <old-app> <new-app>, Rename an app
apps:report [<app>] [<flag>], Display report about an app
apps:unlock <app>, Unlocks an app for deployment
help_content
}
apps_help_cmd() {
if [[ $1 == "apps:help" ]]; then
echo -e 'Usage: dokku apps[:COMMAND]'
echo ''
echo 'Manage Dokku apps'
echo ''
echo 'Example:'
echo ''
echo '$ dokku apps:list'
echo '=====> My Apps'
echo 'example'
echo 'example2'
echo ''
echo 'Additional commands:'
apps_help_content_func | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
apps_help_content_func
else
cat <<help_desc
apps, Manage Dokku apps
help_desc
fi
}
apps_list_cmd() {
cmd-apps-list() {
declare desc="lists all apps"
local cmd="apps"
declare cmd="apps"
[[ "$1" == "$cmd" ]] && shift 1
local app
dokku_log_info2_quiet "My Apps"

View File

@@ -3,12 +3,13 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
app_post_delete() {
trigger-apps-post-delete() {
declare desc="apps post-delete plugin trigger"
local trigger="app_post_delete"
local APP="$1"
declare trigger="post-delete"
declare APP="$1"
local IMAGE_REPO=$(get_app_image_repo "$APP")
if [[ -n $APP ]]; then
if [[ -n "$APP" ]]; then
# remove contents for apps that are symlinks to other folders
rm -rf "${DOKKU_ROOT:?}/$APP/" >/dev/null
# then remove the folder and/or the symlink
@@ -19,4 +20,4 @@ app_post_delete() {
"$DOCKER_BIN" image rm $("$DOCKER_BIN" image list --quiet "$IMAGE_REPO" | xargs) &>/dev/null || true
}
app_post_delete "$@"
trigger-apps-post-delete "$@"

View File

@@ -5,13 +5,12 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
apps_clone_cmd() {
cmd-apps-clone() {
declare desc="clones an app"
declare cmd="apps:clone" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="apps:clone"
[[ "$1" == "$cmd" ]] && shift 1
declare OLD_APP="$1" NEW_APP="$2"
local IGNORE_EXISTING=false
local SKIP_REBUILD=false
local IGNORE_EXISTING=false SKIP_REBUILD=false
for arg in "$@"; do
[[ "$arg" == "--skip-deploy" ]] && shift 1 && SKIP_REBUILD=true
@@ -56,4 +55,4 @@ apps_clone_cmd() {
dokku_log_info1_quiet "Cloning $OLD_APP to $NEW_APP... done"
}
apps_clone_cmd "$@"
cmd-apps-clone "$@"

View File

@@ -3,10 +3,13 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
apps_create_cmd() {
cmd-apps-create() {
declare desc="creates app via command line"
local cmd="apps:create"
apps_create "$2"
declare cmd="apps:create"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
apps_create "$APP"
}
apps_create_cmd "$@"
cmd-apps-create "$@"

View File

@@ -4,4 +4,4 @@ set -eo pipefail
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
dokku_log_warn "Deprecated: Please use apps:list"
apps_list_cmd "$@"
cmd-apps-list "$@"

View File

@@ -4,14 +4,17 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
apps_destroy_cmd() {
cmd-apps-destroy() {
declare desc="destroys an app"
local cmd="apps:destroy"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ "$2" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory"
[[ "$3" == "force" ]] && export DOKKU_APPS_FORCE_DELETE=1
local APP="$2"
declare cmd="apps:destroy"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" FORCE="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ "$APP" == "tls" ]] && dokku_log_fail "Unable to destroy tls directory"
[[ "$FORCE" == "force" ]] && export DOKKU_APPS_FORCE_DELETE=1
apps_destroy "$APP"
}
apps_destroy_cmd "$@"
cmd-apps-destroy "$@"

View File

@@ -3,9 +3,9 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
apps_exists_cmd() {
cmd-apps-exist() {
declare desc="checks if an app exists"
local cmd="apps:exists"
declare cmd="apps:exists"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
@@ -15,4 +15,4 @@ apps_exists_cmd() {
dokku_log_info1 "App exists"
}
apps_exists_cmd "$@"
cmd-apps-exist "$@"

View File

@@ -3,4 +3,4 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
apps_list_cmd "$@"
cmd-apps-list "$@"

View File

@@ -4,16 +4,15 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
apps_lock_cmd() {
cmd-apps-lock() {
declare desc="locks an app for deployment"
declare cmd="apps:lock"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$APP"
touch "$DOKKU_ROOT/$APP/.deploy.lock" || dokku_log_fail "Unable to create deploy lock"
dokku_log_info1 "Deploy lock created"
}
apps_lock_cmd "$@"
cmd-apps-lock "$@"

View File

@@ -4,11 +4,12 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
apps_locked_cmd() {
cmd-apps-locked() {
declare desc="checks if an app is locked for deployment"
declare cmd="apps:locked"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$APP"
local LOCKED="$(apps_is_locked "$APP")"
@@ -19,4 +20,4 @@ apps_locked_cmd() {
dokku_log_quiet "Deploy lock exists"
}
apps_locked_cmd "$@"
cmd-apps-locked "$@"

View File

@@ -5,13 +5,14 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
apps_rename_cmd() {
cmd-apps-rename() {
declare desc="renames an app"
local cmd="apps:rename"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$3" ]] && dokku_log_fail "Name is already taken"
local OLD_APP="$2"
local NEW_APP="$3"
declare cmd="apps:rename"
[[ "$1" == "$cmd" ]] && shift 1
declare OLD_APP="$1" NEW_APP="$2"
[[ -z "$OLD_APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$NEW_APP" ]] && dokku_log_fail "Name is already taken"
local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache"
local OLD_CACHE_HOST_DIR="$DOKKU_HOST_ROOT/$OLD_APP/cache"
@@ -34,4 +35,4 @@ apps_rename_cmd() {
echo "Renaming $OLD_APP to $NEW_APP... done"
}
apps_rename_cmd "$@"
cmd-apps-rename "$@"

View File

@@ -4,7 +4,7 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/internal-functions"
apps_unlock_cmd() {
cmd-apps-unlock() {
declare desc="unlocks an app for deployment"
declare cmd="apps:unlock"
[[ "$1" == "$cmd" ]] && shift 1
@@ -21,4 +21,4 @@ apps_unlock_cmd() {
dokku_log_info1 "Deploy lock removed"
}
apps_unlock_cmd "$@"
cmd-apps-unlock "$@"

View File

@@ -3,9 +3,9 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
trigger-builder-build-builder-dockerfile() {
trigger-builder-dockerfile-builder-build() {
declare desc="builder-dockerfile builder-build plugin trigger"
declare trigger="trigger-builder-build-builder-dockerfile"
declare trigger="builder-build"
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3"
if [[ "$BUILDER_TYPE" != "dockerfile" ]]; then
@@ -42,4 +42,4 @@ trigger-builder-build-builder-dockerfile() {
plugn trigger post-build-dockerfile "$APP"
}
trigger-builder-build-builder-dockerfile "$@"
trigger-builder-dockerfile-builder-build "$@"

View File

@@ -2,9 +2,9 @@
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
trigger-builder-release-builder-dockerfile() {
trigger-builder-dockerfile-builder-release() {
declare desc="builder-dockerfile builder-release plugin trigger"
declare trigger="trigger-builder-release-builder-dockerfile"
declare trigger="builder-release"
declare BUILDER_TYPE="$1" APP="$2" IMAGE_TAG="$3"
if [[ "$BUILDER_TYPE" != "dockerfile" ]]; then
@@ -16,4 +16,4 @@ trigger-builder-release-builder-dockerfile() {
plugn trigger post-release-dockerfile "$APP" "$IMAGE_TAG"
}
trigger-builder-release-builder-dockerfile "$@"
trigger-builder-dockerfile-builder-release "$@"

View File

@@ -3,9 +3,9 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
trigger-builder-build-builder-herokuish() {
trigger-builder-herokuish-builder-build() {
declare desc="builder-herokuish builder-build plugin trigger"
declare trigger="trigger-builder-build-builder-herokuish"
declare trigger="builder-build"
declare BUILDER_TYPE="$1" APP="$2" SOURCECODE_WORK_DIR="$3"
if [[ "$BUILDER_TYPE" != "herokuish" ]]; then
@@ -62,4 +62,4 @@ trigger-builder-build-builder-herokuish() {
plugn trigger post-build-buildpack "$APP" "$SOURCECODE_WORK_DIR"
}
trigger-builder-build-builder-herokuish "$@"
trigger-builder-herokuish-builder-build "$@"

View File

@@ -3,9 +3,9 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
trigger-builder-release-builder-herokuish() {
trigger-builder-herokuish-builder-release() {
declare desc="builder-herokuish builder-release plugin trigger"
declare trigger="trigger-builder-release-builder-herokuish"
declare trigger="builder-release"
declare BUILDER_TYPE="$1" APP="$2" IMAGE_TAG="$3"
if [[ "$BUILDER_TYPE" != "herokuish" ]]; then
@@ -39,4 +39,4 @@ trigger-builder-release-builder-herokuish() {
plugn trigger post-release-buildpack "$APP" "$IMAGE_TAG"
}
trigger-builder-release-builder-herokuish "$@"
trigger-builder-herokuish-builder-release "$@"

View File

@@ -3,13 +3,11 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
trigger-docker-args-builder-herokuish() {
trigger-builder-herokuish-docker-args() {
declare desc="builder-herokuish docker-args plugin trigger"
declare trigger="trigger-docker-args-builder-herokuish"
local APP="$1"
local STDIN
local DOKKU_APP_TYPE
local DOKKU_APP_USER
declare trigger="docker-args"
declare APP="$1"
local STDIN DOKKU_APP_TYPE DOKKU_APP_USER
STDIN=$(cat)
DOKKU_APP_TYPE=$(config_get "$APP" DOKKU_APP_TYPE || true)
@@ -25,4 +23,4 @@ trigger-docker-args-builder-herokuish() {
echo -n "$docker_args"
}
trigger-docker-args-builder-herokuish "$@"
trigger-builder-herokuish-docker-args "$@"

View File

@@ -4,9 +4,9 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
trigger-pre-build-buildpack-builder-herokuish() {
trigger-builder-herokuish-pre-build-buildpack() {
declare desc="builder-herokuish pre-build-buildpack plugin trigger"
declare trigger="trigger-pre-build-buildpack-builder-herokuish"
declare trigger="pre-build-buildpack"
declare APP="$1"
local IMAGE CID
@@ -40,4 +40,4 @@ trigger-pre-build-buildpack-builder-herokuish() {
"$DOCKER_BIN" container commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" "$CID" "$IMAGE" >/dev/null
}
trigger-pre-build-buildpack-builder-herokuish "$@"
trigger-builder-herokuish-pre-build-buildpack "$@"

View File

@@ -14,7 +14,7 @@ import (
const (
helpHeader = `Usage: dokku buildpacks[:COMMAND]
Manages buildpacks settings for an app
Manage buildpacks settings for an app
Additional commands:`
@@ -44,7 +44,7 @@ func main() {
if err == nil && strings.Contains(string(output), "--all") {
fmt.Println(helpContent)
} else {
fmt.Print("\n buildpacks, Manages buildpack settings for an app\n")
fmt.Print("\n buildpacks, Manage buildpack settings for an app\n")
}
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env bash
[[ " help certs:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/certs/internal-functions"
source "$PLUGIN_AVAILABLE_PATH/certs/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | certs:help)
certs_help_cmd "$@"
cmd-certs-help "$@"
;;
*)

41
plugins/certs/help-functions Executable file
View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-certs-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="certs"
local plugin_description="Manage SSL (TLS) certs"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
certs <app>, [DEPRECATED] Alternative for certs:report
certs:add <app> CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin
certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate
certs:generate <app> DOMAIN, Generate a key and certificate signing request (and self-signed certificate)
certs:info <app>, [DEPRECATED] Alternative for certs:report
certs:key <app> CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate
certs:remove <app>, Remove an SSL Endpoint from an app
certs:report [<app>] [<flag>], Displays an ssl report for one or more apps
certs:rollback <app>, [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app
certs:update <app> CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin
help_content
}

View File

@@ -6,9 +6,10 @@ set -eo pipefail
cmd-certs-report() {
declare desc="displays an ssl report for one or more apps"
local cmd="certs:report"
declare cmd="certs:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
@@ -71,46 +72,15 @@ cmd-certs-report-single() {
fi
}
certs_help_content_func() {
declare desc="return certs plugin help content"
cat <<help_content
certs <app>, [DEPRECATED] Alternative for certs:report
certs:add <app> CRT KEY, Add an ssl endpoint to an app. Can also import from a tarball on stdin
certs:chain CRT [CRT ...], [NOT IMPLEMENTED] Print the ordered and complete chain for the given certificate
certs:generate <app> DOMAIN, Generate a key and certificate signing request (and self-signed certificate)
certs:info <app>, [DEPRECATED] Alternative for certs:report
certs:key <app> CRT KEY [KEY ...], [NOT IMPLEMENTED] Print the correct key for the given certificate
certs:remove <app>, Remove an SSL Endpoint from an app
certs:report [<app>] [<flag>], Displays an ssl report for one or more apps
certs:rollback <app>, [NOT IMPLEMENTED] Rollback an SSL Endpoint for an app
certs:update <app> CRT KEY, Update an SSL Endpoint on an app. Can also import from a tarball on stdin
help_content
}
certs_help_cmd() {
if [[ $1 == "certs:help" ]]; then
echo -e 'Usage: dokku certs[:COMMAND]'
echo ''
echo 'Manage Dokku apps SSL (TLS) certs.'
echo ''
echo 'Additional commands:'
certs_help_content_func | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
certs_help_content_func
else
cat <<help_desc
certs, Manage Dokku apps SSL (TLS) certs
help_desc
fi
}
certs_info_cmd() {
cmd-certs-info() {
# This is here because it's used in both the info and the default
declare desc="prints SSL certificate info for app"
local cmd="certs:info"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
local APP="$2"
declare cmd="certs:info"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
if is_ssl_enabled "$APP"; then

View File

@@ -2,8 +2,9 @@
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
certs_post_app_clone_setup() {
trigger-certs-post-app-clone-setup() {
declare desc="removes cert file when setting up a clone"
declare trigger="post-app-clone-setup"
declare OLD_APP="$1" NEW_APP="$2"
local APP_DIR="$DOKKU_ROOT/$NEW_APP"
@@ -11,4 +12,4 @@ certs_post_app_clone_setup() {
plugn trigger post-certs-remove "$NEW_APP"
}
certs_post_app_clone_setup "$@"
trigger-certs-post-app-clone-setup "$@"

View File

@@ -28,14 +28,14 @@ is_file_import() {
return 1
}
certs_set() {
cmd-certs-set() {
declare desc="imports an SSL cert/key combo either on STDIN via a tarball or from specified cert/key filenames"
local cmd="$1"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
local APP="$2"
local CRT_FILE="$3"
local KEY_FILE="$4"
declare cmd="$1"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" CRT_FILE="$2" KEY_FILE="$3"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
if is_file_import "$CRT_FILE" "$KEY_FILE"; then
@@ -79,4 +79,4 @@ certs_set() {
plugn trigger post-domains-update "$APP"
}
certs_set "$@"
cmd-certs-set "$@"

View File

@@ -4,4 +4,4 @@ set -eo pipefail
source "$PLUGIN_AVAILABLE_PATH/certs/internal-functions"
dokku_log_warn "Deprecated: Please use certs:report"
certs_info_cmd "$@"
cmd-certs-info "$@"

View File

@@ -4,10 +4,12 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
certs_generate_cmd() {
cmd-certs-generate() {
declare desc="generates a self-signed SSL certificate/key combo"
declare APP="$2" DOMAIN="$3"
local cmd="certs:generate"
declare cmd="certs:generate"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
@@ -37,4 +39,4 @@ certs_generate_cmd() {
fi
}
certs_generate_cmd "$@"
cmd-certs-generate "$@"

View File

@@ -4,4 +4,4 @@ set -eo pipefail
source "$PLUGIN_AVAILABLE_PATH/certs/internal-functions"
dokku_log_warn "Deprecated: Please use certs:report"
certs_info_cmd "$@"
cmd-certs-info "$@"

View File

@@ -3,12 +3,14 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
certs_remove_cmd() {
cmd-certs-remove() {
declare desc="removes SSL cert/key from specified app"
local cmd="certs:remove"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
local APP="$2"
declare cmd="certs:remove"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
if [[ -d "$APP_SSL_PATH" ]]; then
@@ -21,4 +23,4 @@ certs_remove_cmd() {
fi
}
certs_remove_cmd "$@"
cmd-certs-remove "$@"

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env bash
[[ " help checks:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/checks/internal-functions"
source "$PLUGIN_AVAILABLE_PATH/checks/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | checks:help)
checks_help_cmd "$@"
cmd-checks-help "$@"
;;
*)

37
plugins/checks/help-functions Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-checks-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="checks"
local plugin_description="Manage zero-downtime settings"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
checks <app>, [DEPRECATED] Alternative for checks:report
checks:disable <app> [process-type(s)], Disable zero-downtime deployment for all processes (or comma-separated process-type list) ***WARNING: this will cause downtime during deployments***
checks:enable <app> [process-type(s)], Enable zero-downtime deployment for all processes (or comma-separated process-type list)
checks:report [<app>] [<flag>], Displays a checks report for one or more apps
checks:run <app> [process-type(s)], Runs zero-downtime checks for all processes (or comma-separated process-type list)
checks:skip <app> [process-type(s)], Skip zero-downtime checks for all processes (or comma-separated process-type list)
help_content
}

View File

@@ -56,5 +56,12 @@ migrate_checks_vars_0_6_0() {
done
}
migrate_checks_vars_0_5_0 "$@"
migrate_checks_vars_0_6_0 "$@"
trigger-checks-install() {
declare desc="installs the checks plugin"
declare trigger="install"
migrate_checks_vars_0_5_0 "$@"
migrate_checks_vars_0_6_0 "$@"
}
trigger-checks-install "$@"

View File

@@ -6,9 +6,10 @@ set -eo pipefail
cmd-checks-report() {
declare desc="shows reports for an app"
local cmd="checks:report"
declare cmd="checks:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
@@ -65,35 +66,6 @@ cmd-checks-report-single() {
fi
}
checks_help_content_func() {
declare desc="return checks plugin help content"
cat <<help_content
checks <app>, [DEPRECATED] Alternative for checks:report
checks:disable <app> [process-type(s)], Disable zero-downtime deployment for all processes (or comma-separated process-type list) ***WARNING: this will cause downtime during deployments***
checks:enable <app> [process-type(s)], Enable zero-downtime deployment for all processes (or comma-separated process-type list)
checks:report [<app>] [<flag>], Displays a checks report for one or more apps
checks:run <app> [process-type(s)], Runs zero-downtime checks for all processes (or comma-separated process-type list)
checks:skip <app> [process-type(s)], Skip zero-downtime checks for all processes (or comma-separated process-type list)
help_content
}
checks_help_cmd() {
if [[ $1 == "checks:help" ]]; then
echo -e 'Usage: dokku checks[:COMMAND]'
echo ''
echo 'Manage zero-downtime settings.'
echo ''
echo 'Additional commands:'
checks_help_content_func | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
checks_help_content_func
else
cat <<help_desc
checks, Manage zero-downtime settings
help_desc
fi
}
fn-checks-disabled-list() {
declare APP="$1"

View File

@@ -4,13 +4,15 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
checks_main_cmd() {
cmd-checks-default() {
declare desc="displays app zero-downtime checks status"
local cmd="checks"
declare cmd="checks"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
local APPS=$(dokku_apps)
if [[ -n "$1" ]]; then
local APPS="$1"
if [[ -n "$APP" ]]; then
local APPS="$APP"
fi
dokku_log_warn "Deprecated: Please use checks:report"
@@ -26,4 +28,4 @@ checks_main_cmd() {
done
}
checks_main_cmd "$@"
cmd-checks-default "$@"

View File

@@ -4,11 +4,12 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
checks_disable_cmd() {
cmd-checks-disable() {
declare desc="disable zero-downtime checks for app/proctypes"
local cmd="checks:disable"
declare cmd="checks:disable"
[[ "$1" == "$cmd" ]] && shift 1
local APP="$1"
declare APP="$1"
verify_app_name "$APP"
local PROCTYPES="${2:-_all_}"
local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED || true)
@@ -43,4 +44,4 @@ checks_disable_cmd() {
fi
}
checks_disable_cmd "$@"
cmd-checks-disable "$@"

View File

@@ -4,11 +4,12 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
checks_enable_cmd() {
cmd-checks-enable() {
declare desc="enable zero-downtime checks for app/proctypes"
local cmd="checks:enable"
declare cmd="checks:enable"
[[ "$1" == "$cmd" ]] && shift 1
local APP="$1"
declare APP="$1"
verify_app_name "$APP"
local PROCTYPES="${2:-_all_}"
@@ -42,4 +43,4 @@ checks_enable_cmd() {
fi
}
checks_enable_cmd "$@"
cmd-checks-enable "$@"

View File

@@ -67,11 +67,12 @@ check_process() {
plugn trigger check-deploy "$APP" "$CONTAINER_ID" "$PROC_TYPE" "$PORT" "$IP"
}
checks_run_cmd() {
cmd-checks-run() {
declare desc="run zero-downtime checks for app/proctypes"
local cmd="checks:run"
declare cmd="checks:run"
[[ "$1" == "$cmd" ]] && shift 1
local APP="$1"
declare APP="$1"
verify_app_name "$APP"
local PROCTYPES="${2:-_all_}"
@@ -94,4 +95,4 @@ checks_run_cmd() {
fi
}
checks_run_cmd "$@"
cmd-checks-run "$@"

View File

@@ -4,11 +4,12 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
checks_skip_cmd() {
cmd-checks-skip() {
declare desc="skip zero-downtime checks for app/proctypes"
local cmd="checks:skip"
declare cmd="checks:skip"
[[ "$1" == "$cmd" ]] && shift 1
local APP="$1"
declare APP="$1"
verify_app_name "$APP"
local PROCTYPES="${2:-_all_}"
local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED || true)
@@ -43,4 +44,4 @@ checks_skip_cmd() {
fi
}
checks_skip_cmd "$@"
cmd-checks-skip "$@"

View File

@@ -295,8 +295,7 @@ get_running_image_tag() {
is_image_herokuish_based() {
declare desc="returns true if app image is based on herokuish"
declare IMAGE="$1"
declare APP="$2"
declare IMAGE="$1" APP="$2"
local DOKKU_APP_USER
if [[ -n "$APP" ]]; then
DOKKU_APP_USER=$(config_get "$APP" DOKKU_APP_USER || true)
@@ -571,7 +570,7 @@ dokku_release() {
plugn trigger builder-release "$IMAGE_SOURCE_TYPE" "$APP" "$IMAGE_TAG"
}
dokku_deploy_cmd() {
cmd-deploy() {
declare desc="deploy phase"
declare APP="$1" IMAGE_TAG="$2"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
@@ -613,7 +612,7 @@ release_and_deploy() {
if [[ "$DOKKU_SKIP_DEPLOY" != "true" ]]; then
dokku_log_info1 "Deploying $APP ($IMAGE)..."
dokku_deploy_cmd "$APP" "$IMAGE_TAG"
cmd-deploy "$APP" "$IMAGE_TAG"
dokku_log_info2 "Application deployed:"
get_app_urls urls "$APP" | sed "s/^/ /"
else

View File

@@ -4,8 +4,9 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
config_docker_args() {
trigger-config-docker-args() {
declare desc="config docker-args plugin trigger"
declare trigger="docker-args"
declare APP="$1" IMAGE_TAG="$2"
local ENV_ARGS IMAGE STDIN trigger
@@ -22,4 +23,4 @@ config_docker_args() {
fi
}
config_docker_args "$@"
trigger-config-docker-args "$@"

View File

@@ -13,9 +13,9 @@ import (
)
const (
helpHeader = `Usage: dokku config [<app>|--global]
helpHeader = `Usage: dokku config[:COMMAND]
Display all global or app-specific config vars
Manage global and app-specific config vars
Additional commands:`
@@ -55,7 +55,7 @@ func main() {
if err == nil && strings.Contains(string(output), "--all") {
fmt.Println(helpContent)
} else {
fmt.Print("\n config, Manages global and app-specific config vars\n")
fmt.Print("\n config, Manage global and app-specific config vars\n")
}
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))

View File

@@ -1,39 +1,12 @@
#!/usr/bin/env bash
[[ " help docker-options:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/docker-options/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
docker_options_help_content_func() {
declare desc="return docker-options plugin help content"
cat <<help_content
docker-options <app> [phase(s)], [DEPRECATED] Alternative for docker-options:report
docker-options:add <app> <phase(s)> OPTION, Add Docker option to app for phase (comma separated phase list)
docker-options:clear <app> [phase(s)], Clear a docker options from application with an optional phase (comma separated phase list)
docker-options:remove <app> <phase(s)> OPTION, Remove Docker option from app for phase (comma separated phase list)
docker-options:report [<app>] [<flag>], Displays a docker options report for one or more apps
help_content
}
docker_options_help_cmd() {
if [[ $1 == "docker-options:help" ]]; then
echo -e 'Usage: dokku docker-options[:COMMAND]'
echo ''
echo 'Display app'"'"'s Docker options for all phases.'
echo ''
echo 'Additional commands:'
docker_options_help_content_func | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
docker_options_help_content_func
else
cat <<help_desc
docker-options, Pass options to Docker the various stages of an app
help_desc
fi
}
case "$1" in
help | docker-options:help)
docker_options_help_cmd "$@"
cmd-docker-options-help "$@"
;;
*)

View File

@@ -2,12 +2,11 @@
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
docker_args() {
trigger-docker-options-docker-args() {
declare desc="docker args plugin trigger"
local trigger="$0"
declare trigger="$0"
declare APP="$1" IMAGE_SOURCE_TYPE="$2"
local STDIN=$(cat)
local APP="$1"
local IMAGE_SOURCE_TYPE="$2"
case "$0" in
*docker-args-build)
@@ -77,4 +76,4 @@ docker_args() {
echo -n "$STDIN$output"
}
docker_args "$@"
trigger-docker-options-docker-args "$@"

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-docker-options-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="docker-options"
local plugin_description="Manage docker options for an app"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
docker-options <app> [phase(s)], [DEPRECATED] Alternative for docker-options:report
docker-options:add <app> <phase(s)> OPTION, Add Docker option to app for phase (comma separated phase list)
docker-options:clear <app> [phase(s)], Clear a docker options from application with an optional phase (comma separated phase list)
docker-options:remove <app> <phase(s)> OPTION, Remove Docker option from app for phase (comma separated phase list)
docker-options:report [<app>] [<flag>], Displays a docker options report for one or more apps
help_content
}

View File

@@ -6,9 +6,10 @@ set -eo pipefail
cmd-docker-options-report() {
declare desc="displays a docker options report for one or more apps"
local cmd="docker-options:report"
declare cmd="docker-options:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"

View File

@@ -4,16 +4,18 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
docker_options_add_cmd() {
cmd-docker-options-add() {
declare desc="Add a docker option to application"
local cmd="docker-options:add"
declare cmd="docker-options:add"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$2" && local APP="$2"
read -ra passed_phases <<<"$(get_phases "$3")"
shift 3 # everything else passed is the docker option
verify_app_name "$APP"
read -ra passed_phases <<<"$(get_phases "$2")"
shift 2 # everything else passed is the docker option
local passed_docker_option="$*"
[[ -z "$passed_docker_option" ]] && dokku_log_fail "Please specify docker options to add to the phase"
add_passed_docker_option passed_phases[@] "${passed_docker_option[@]}"
}
docker_options_add_cmd "$@"
cmd-docker-options-add "$@"

View File

@@ -6,8 +6,8 @@ source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
cmd-docker-options-clear() {
declare desc="clear a docker options from application"
declare cmd="docker-options:clear" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="docker-options:clear"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" PHASES="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"

View File

@@ -4,13 +4,15 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
docker_options_main_cmd() {
cmd-docker-options-default() {
declare desc="Display applications docker options"
local cmd="docker-options"
dokku_log_warn "Deprecated: Please use docker-options:report"
declare cmd="docker-options"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$2" && local APP="$2"
read -ra passed_phases <<<"$(get_phases "$3")"
dokku_log_warn "Deprecated: Please use docker-options:report"
verify_app_name "$APP"
read -ra passed_phases <<<"$(get_phases "$2")"
if [[ ! "${passed_phases[@]}" ]]; then
display_all_phases_options
else
@@ -18,4 +20,4 @@ docker_options_main_cmd() {
fi
}
docker_options_main_cmd "$@"
cmd-docker-options-default "$@"

View File

@@ -4,16 +4,18 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
docker_options_remove_cmd() {
cmd-docker-options-remove() {
declare desc="Remove a docker option from application"
local cmd="docker-options:remove"
declare cmd="docker-options:remove"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$2" && local APP="$2"
read -ra passed_phases <<<"$(get_phases "$3")"
shift 3 # everything else passed is the docker option
verify_app_name "$APP"
read -ra passed_phases <<<"$(get_phases "$2")"
shift 2 # everything else passed is the docker option
# shellcheck disable=SC2154
[[ -z ${passed_docker_option="$@"} ]] && dokku_log_fail "Please specify docker options to remove from the phase"
remove_passed_docker_option passed_phases[@] "${passed_docker_option[@]}"
}
docker_options_remove_cmd "$@"
cmd-docker-options-remove "$@"

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env bash
[[ " help domains:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/domains/internal-functions"
source "$PLUGIN_AVAILABLE_PATH/domains/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | domains:help)
domains_help_cmd "$@"
cmd-domains-help "$@"
;;
*)

43
plugins/domains/help-functions Executable file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-domains-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="domains"
local plugin_description="Manage domains used by the proxy"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
domains [<app>], [DEPRECATED] Alternative for domains:report
domains:add <app> <domain> [<domain> ...], Add domains to app
domains:add-global <domain> [<domain> ...], Add global domain names
domains:clear <app>, Clear all domains for app
domains:clear-global, Clear global domain names
domains:disable <app>, Disable VHOST support
domains:enable <app>, Enable VHOST support
domains:remove <app> <domain> [<domain> ...], Remove domains from app
domains:remove-global <domain> [<domain> ...], Remove global domain names
domains:report [<app>|--global] [<flag>], Displays a domains report for one or more apps
domains:set <app> <domain> [<domain> ...], Set domains for app
domains:set-global <domain> [<domain> ...], Set global domain names
help_content
}

View File

@@ -2,9 +2,16 @@
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
shopt -s nullglob
for app in $DOKKU_ROOT/*/CONTAINER; do
APP=$(basename "$(dirname "$app")")
domains_setup "$APP"
done
trigger-domains-install() {
declare desc="domains install trigger"
declare trigger="install"
shopt -s nullglob
for app in $DOKKU_ROOT/*/CONTAINER; do
APP=$(basename "$(dirname "$app")")
domains_setup "$APP"
done
}
trigger-domains-install "$@"

View File

@@ -6,9 +6,10 @@ set -eo pipefail
cmd-domains-report() {
declare desc="displays a domains report for one or more apps"
local cmd="domains:report"
declare cmd="domains:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ "$APP" == "--global" ]]; then
cmd-domains-report-single "$APP" "$INFO_FLAG"
@@ -84,41 +85,6 @@ cmd-domains-report-single() {
fi
}
domains_help_content_func() {
declare desc="return domains plugin help content"
cat <<help_content
domains [<app>], [DEPRECATED] Alternative for domains:report
domains:add <app> <domain> [<domain> ...], Add domains to app
domains:add-global <domain> [<domain> ...], Add global domain names
domains:clear <app>, Clear all domains for app
domains:clear-global, Clear global domain names
domains:disable <app>, Disable VHOST support
domains:enable <app>, Enable VHOST support
domains:remove <app> <domain> [<domain> ...], Remove domains from app
domains:remove-global <domain> [<domain> ...], Remove global domain names
domains:report [<app>|--global] [<flag>], Displays a domains report for one or more apps
domains:set <app> <domain> [<domain> ...], Set domains for app
domains:set-global <domain> [<domain> ...], Set global domain names
help_content
}
domains_help_cmd() {
if [[ $1 == "domains:help" ]]; then
echo -e 'Usage: dokku domains[:COMMAND]'
echo ''
echo 'Manage vhost domains used by the Dokku proxy.'
echo ''
echo 'Additional commands:'
domains_help_content_func | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
domains_help_content_func
else
cat <<help_desc
domains, Manage vhost domains used by the Dokku proxy
help_desc
fi
}
fn-domains-app-enabled() {
declare APP="$1"
local DOMAINS_APP_ENABLED=false

View File

@@ -2,12 +2,13 @@
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
domains_post_app_clone_setup() {
trigger-domains-post-app-clone-setup() {
declare desc="removes domain files when setting up a clone"
declare trigger="post-app-clone-setup"
declare OLD_APP="$1" NEW_APP="$2"
local APP_DIR="$DOKKU_ROOT/$NEW_APP"
rm -rf "$APP_DIR/URLS" "$APP_DIR/VHOST"
}
domains_post_app_clone_setup "$@"
trigger-domains-post-app-clone-setup "$@"

View File

@@ -4,14 +4,15 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_add_cmd() {
cmd-domains-add() {
declare desc="adds domains to app via command line"
local cmd="domains:add"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
declare cmd="domains:add"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
shift 1
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
domains_add "$@"
}
domains_add_cmd "$@"
cmd-domains-add "$@"

View File

@@ -4,13 +4,14 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_add_global_cmd() {
cmd-domains-add-global() {
declare desc="add global domain names via command line"
local cmd="domains:add-global"
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
declare cmd="domains:add-global"
[[ "$1" == "$cmd" ]] && shift 1
declare DOMAIN_NAME="$1"
shift 1
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
domains_add_global "$@"
}
domains_add_global_cmd "$@"
cmd-domains-add-global "$@"

View File

@@ -4,12 +4,14 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_clear_cmd() {
cmd-domains-clear() {
declare desc="clear all app domains"
local cmd="domains:clear"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
local APP="$2"
declare cmd="domains:clear"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
rm -f "$APP_VHOST_PATH"
@@ -18,4 +20,4 @@ domains_clear_cmd() {
dokku_log_info1 "Cleared domains in $APP"
}
domains_clear_cmd "$@"
cmd-domains-clear "$@"

View File

@@ -4,13 +4,13 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_clear_global_cmd() {
cmd-domains-clear-global() {
declare desc="clear global domain names via command line"
local cmd="domains:clear-global"
shift 1
declare cmd="domains:clear-global"
[[ "$1" == "$cmd" ]] && shift 1
dokku_log_info1_quiet "Clearing global domains"
domains_clear_global "$@"
}
domains_clear_global_cmd "$@"
cmd-domains-clear-global "$@"

View File

@@ -4,10 +4,11 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_main_cmd() {
cmd-domains-default() {
declare desc="print app domains"
local cmd="domains"
local APP="$2"
declare cmd="domains"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
dokku_log_warn "Deprecated: Please use domains:report"
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then
@@ -30,4 +31,4 @@ domains_main_cmd() {
fi
}
domains_main_cmd "$@"
cmd-domains-default "$@"

View File

@@ -4,11 +4,14 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_disable_cmd() {
cmd-domains-disable() {
declare desc="disable domains/VHOST support via command line"
local cmd="domains:disable"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_disable "$2"
declare cmd="domains:disable"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
domains_disable "$APP"
}
domains_disable_cmd "$@"
cmd-domains-disable "$@"

View File

@@ -4,11 +4,14 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_enable_cmd() {
cmd-domains-enable() {
declare desc="enable domains/VHOST support via command line"
local cmd="domains:enable"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_enable "$2"
declare cmd="domains:enable"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
domains_enable "$APP"
}
domains_enable_cmd "$@"
cmd-domains-enable "$@"

View File

@@ -4,14 +4,15 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_remove_cmd() {
cmd-domains-remove() {
declare desc="removes domains from app via command line"
local cmd="domains:remove"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
declare cmd="domains:remove"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
shift 1
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
domains_remove "$@"
}
domains_remove_cmd "$@"
cmd-domains-remove "$@"

View File

@@ -4,13 +4,14 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_remove_global_cmd() {
cmd-domains-remove-global() {
declare desc="remove global domain names via command line"
local cmd="domains:remove-global"
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
declare cmd="domains:remove-global"
[[ "$1" == "$cmd" ]] && shift 1
declare DOMAIN_NAME="$1"
shift 1
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
domains_remove_global "$@"
}
domains_remove_global_cmd "$@"
cmd-domains-remove-global "$@"

View File

@@ -4,14 +4,15 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_set_cmd() {
cmd-domains-set() {
declare desc="set domains for app via command line"
local cmd="domains:set"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
declare cmd="domains:set"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
shift 1
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
domains_set "$@"
}
domains_set_cmd "$@"
cmd-domains-set "$@"

View File

@@ -4,13 +4,14 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_set_global_cmd() {
cmd-domains-set-global() {
declare desc="set global domain names via command line"
local cmd="domains:set-global"
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
declare cmd="domains:set-global"
[[ "$1" == "$cmd" ]] && shift 1
declare DOMAIN_NAME="$1"
shift 1
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 <domain> [<domain> ...]"
domains_set_global "$@"
}
domains_set_global_cmd "$@"
cmd-domains-set-global "$@"

View File

@@ -4,11 +4,14 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_setup_cmd() {
cmd-domains-setup() {
declare desc="setup domains to default state via command line"
local cmd="domains:setup"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_setup "$2"
declare cmd="domains:setup"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
domains_setup "$APP"
}
domains_setup_cmd "$@"
cmd-domains-setup "$@"

View File

@@ -1,27 +1,12 @@
#!/usr/bin/env bash
[[ " help enter:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/enter/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | enter:help)
help_content_func() {
declare desc="return enter plugin help content"
cat <<help_content
enter <app> [<container-type> || --container-id <container-id>], Connect to a specific app container
help_content
}
if [[ $1 == "enter:help" ]]; then
echo -e 'Usage: dokku enter <app>'
echo ''
echo 'Allows you to access a bash prompt inside the container of the app.'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
else
help_content_func
fi
cmd-enter-help "$@"
;;
*)

32
plugins/enter/help-functions Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-enter-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="enter"
local plugin_description="Enter running app containers"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
enter <app> [<container-type> || --container-id <container-id>], Connect to a specific app container
help_content
}

View File

@@ -4,17 +4,18 @@ set -eo pipefail
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
enter_default_cmd() {
cmd-enter-default() {
declare desc="enters running app container of specified proc type"
local cmd="enter"
local APP="$2"
local CONTAINER_TYPE="$3"
declare cmd="enter"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" CONTAINER_TYPE="$2" CONTAINER_ID_FLAG="$3" CONTAINER_ID="$4"
local IMAGE_TAG=$(get_running_image_tag "$APP")
local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG")
verify_app_name "$APP"
local AVAILABLE_CONTAINER_TYPES=($(get_app_running_container_types "$APP"))
if [[ -z "$3" ]]; then
if [[ -z "$CONTAINER_TYPE" ]]; then
if [[ ${#AVAILABLE_CONTAINER_TYPES[@]} -gt 1 ]]; then
dokku_log_warn "No container type specified."
dokku_log_fail "Available types for app ($APP): ${AVAILABLE_CONTAINER_TYPES[*]}"
@@ -23,9 +24,9 @@ enter_default_cmd() {
fi
fi
if [[ "$3" == "--container-id" ]]; then
if [[ "$CONTAINER_ID_FLAG" == "--container-id" ]]; then
local DOKKU_APP_CIDS=($(get_app_container_ids "$APP"))
if [[ -z "$4" ]]; then
if [[ -z "$CONTAINER_ID" ]]; then
dokku_log_warn "No container id specified."
dokku_log_fail "Available ids for app ($APP): ${DOKKU_APP_CIDS[*]}"
fi
@@ -34,7 +35,7 @@ enter_default_cmd() {
dokku_log_fail "Available ids for app ($APP): ${DOKKU_APP_CIDS[*]}"
fi
local ID=$(printf -- '%s\n' "${DOKKU_APP_CIDS[@]}" | grep -e "^$4")
shift 4
shift 3
else
local DOKKU_APP_CIDS=($(get_app_container_ids "$APP" "$CONTAINER_TYPE"))
local ID=${DOKKU_APP_CIDS[0]}
@@ -42,10 +43,10 @@ enter_default_cmd() {
dokku_log_warn "No containers found for type '$CONTAINER_TYPE'"
dokku_log_fail "Available types for app ($APP): ${AVAILABLE_CONTAINER_TYPES[*]}"
fi
if [[ $3 ]]; then
shift 3
else
if [[ "$CONTAINER_ID_FLAG" ]]; then
shift 2
else
shift 1
fi
fi
@@ -63,4 +64,4 @@ enter_default_cmd() {
"$DOCKER_BIN" container exec $DOKKU_RUN_OPTS $ID $EXEC_CMD "${@:-$DOKKU_APP_SHELL}"
}
enter_default_cmd "$@"
cmd-enter-default "$@"

View File

@@ -3,18 +3,19 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/git/functions"
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
source "$PLUGIN_AVAILABLE_PATH/git/help-functions"
case "$1" in
git-hook)
git_hook_cmd "$@"
cmd-git-hook "$@"
;;
git-upload-pack)
git_upload_pack_cmd "$@"
cmd-git-upload-pack "$@"
;;
git-*)
git_glob_cmd "$@"
cmd-git-glob "$@"
;;
help | git:help)

View File

@@ -2,9 +2,9 @@
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
git_deploy_source() {
trigger-git-deploy-source() {
declare desc="git deploy-source plugin trigger"
declare trigger="git_deploy_source"
declare trigger="deploy-source"
declare APP="$1"
local STDIN
STDIN=$(cat)
@@ -20,4 +20,4 @@ git_deploy_source() {
fi
}
git_deploy_source "$@"
trigger-git-deploy-source "$@"

View File

@@ -109,7 +109,7 @@ git_trigger_build() {
git_deploy_branch() {
declare desc="retrieve the deploy branch for a given application"
local cmd="git-hook"
declare cmd="git-hook"
local APP="$1"
local DOKKU_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "$APP" "deploy-branch" "")"
@@ -123,11 +123,13 @@ git_deploy_branch() {
fi
}
git_hook_cmd() {
cmd-git-hook() {
declare desc="kick off receive-app trigger from git prereceive hook"
local cmd="git-hook"
local APP="$2"
declare cmd="git-hook"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
local DOKKU_DEPLOY_BRANCH
is_valid_app_name "$APP"
DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")"
@@ -195,10 +197,12 @@ git_receive_app() {
fi
}
git_upload_pack_cmd() {
cmd-git-upload-pack() {
declare desc="executes git-upload-pack"
declare cmd="git-upload-pack"
declare APP="$2"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
APP="$(echo "$APP" | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g' | sed 's/^\///g')"
is_valid_app_name "$APP"
! apps_exists "$APP" >/dev/null 2>&1 && apps_maybe_create "$APP"
@@ -208,9 +212,9 @@ git_upload_pack_cmd() {
plugn trigger git-post-pull "$APP"
}
git_glob_cmd() {
cmd-git-glob() {
declare desc="catch-all for any other git-* commands"
local cmd="git-*"
declare cmd="git-*"
local APP="$(echo "$2" | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g' | sed 's/^\///g')"
local APP_PATH=$DOKKU_ROOT/$APP
is_valid_app_name "$APP"

View File

@@ -6,6 +6,7 @@ set -eo pipefail
trigger-git-git-revision() {
declare desc="fetches the current git revision value for an application"
declare trigger="git-revision"
declare APP="$1"
ENV_VAR_NAME="$(fn-plugin-property-get "git" "$APP" "rev-env-var")"

34
plugins/git/help-functions Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-git-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="git"
local plugin_description="Manage app deploys via git"
if [[ "$CMD" == "$plugin_name:help" ]]; then
echo -e "Usage: dokku $plugin_name[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
git:initialize <app>, Initialize a git repository for an app
git:report [<app>] [<flag>], Displays a git report for one or more apps
git:set <app> <property> (<value>), Set or clear a git property for an app
help_content
}

View File

@@ -7,7 +7,10 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions"
trigger-git-install() {
declare desc="installs the git plugin"
declare trigger="install"
fn-plugin-property-setup "git"
migrate_git_vars_0_12_0 "$@"
}
migrate_git_vars_0_12_0() {
@@ -31,4 +34,3 @@ migrate_git_vars_0_12_0() {
}
trigger-git-install "$@"
migrate_git_vars_0_12_0 "$@"

View File

@@ -6,9 +6,10 @@ set -eo pipefail
cmd-git-report() {
declare desc="displays a git report for one or more apps"
local cmd="git:report"
declare cmd="git:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"
@@ -66,30 +67,3 @@ cmd-git-report-single() {
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
fi
}
git_help_content_func() {
declare desc="return git plugin help content"
cat <<help_content
git:initialize <app>, Initialize a git repository for an app
git:report [<app>] [<flag>], Displays a git report for one or more apps
git:set <app> <property> (<value>), Set or clear a git property for an app
help_content
}
cmd-git-help() {
if [[ $1 == "git:help" ]]; then
echo -e 'Usage: dokku git[:COMMAND]'
echo ''
echo 'Manages the git integration for an app.'
echo ''
echo 'Additional commands:'
git_help_content_func | sort | column -c2 -t -s,
echo ''
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
git_help_content_func
else
cat <<help_desc
git, Manages the git integration for an app
help_desc
fi
}

View File

@@ -5,7 +5,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
trigger-git-post-delete() {
declare desc="destroys the git properties for a given app"
declare trigger="post-delete"
declare APP="$1"
fn-plugin-property-destroy "git" "$APP"
}

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
source "$PLUGIN_AVAILABLE_PATH/git/help-functions"
cmd-git-help "git:help"

View File

@@ -4,15 +4,15 @@ source "$PLUGIN_AVAILABLE_PATH/git/functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
git-initialize-cmd() {
cmd-git-initialize() {
declare desc="initialize a git repository for an app"
local cmd="git:initialize" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="git:initialize"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
is_valid_app_name "$APP"
is_valid_app_name "$APP"
dokku_log_info1_quiet "Initializing git repository for $APP"
fn-git-create-hook "$APP"
}
git-initialize-cmd "$@"
cmd-git-initialize "$@"

View File

@@ -4,12 +4,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
git-set-cmd() {
cmd-git-set() {
declare desc="set or clear a git property for an app"
local cmd="git:set" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="git:set"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=("deploy-branch" "keep-git-dir" "rev-env-var")
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
@@ -33,4 +34,4 @@ git-set-cmd() {
fi
}
git-set-cmd "$@"
cmd-git-set "$@"

Some files were not shown because too many files have changed in this diff Show More