fix: ensure we can call the report subcommand without an app while specifying flags

Closes #2628
This commit is contained in:
Jose Diaz-Gonzalez
2017-03-16 02:33:51 -06:00
parent 4de0e693ca
commit 97e35e796c
8 changed files with 142 additions and 55 deletions

View File

@@ -4,7 +4,8 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/functions" source "$PLUGIN_AVAILABLE_PATH/apps/functions"
report_single_app() { report_single_app() {
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2" declare APP="$1" INFO_FLAG="$2"
local APP_DIR="$DOKKU_ROOT/$APP"
local use_echo; local use_echo;
if [[ "$INFO_FLAG" == "true" ]]; then if [[ "$INFO_FLAG" == "true" ]]; then
use_echo=true use_echo=true
@@ -68,14 +69,23 @@ apps_report_cmd() {
declare desc="displays the app report for one or more apps" declare desc="displays the app report for one or more apps"
local cmd="apps:report" local cmd="apps:report"
local INSTALLED_APPS=$(dokku_apps) local INSTALLED_APPS=$(dokku_apps)
local APP local APP="$2" INFO_FLAG="$3"
if [[ -z $2 ]]; then if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
for APP in $INSTALLED_APPS; do INFO_FLAG="$APP"
report_single_app "$APP" "true" APP=""
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi
if [[ -z "$APP" ]]; then
for app in $INSTALLED_APPS; do
report_single_app "$app" "$INFO_FLAG" | tee || true
done done
else else
report_single_app "$2" "$3" report_single_app "$APP" "$INFO_FLAG"
fi fi
} }

View File

@@ -74,8 +74,9 @@ fn-ssl-verified() {
echo "$SSL_SELF_SIGNED" echo "$SSL_SELF_SIGNED"
} }
certs_report_single_app() { report_single_app() {
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2" declare APP="$1" INFO_FLAG="$2"
local APP_DIR="$DOKKU_ROOT/$APP"
if [[ "$INFO_FLAG" == "true" ]]; then if [[ "$INFO_FLAG" == "true" ]]; then
INFO_FLAG="" INFO_FLAG=""
fi fi
@@ -122,14 +123,24 @@ certs_report_single_app() {
certs_report_cmd() { certs_report_cmd() {
declare desc="displays an ssl report for one or more apps" declare desc="displays an ssl report for one or more apps"
local cmd="certs:report" local cmd="certs:report"
local INSTALLED_APPS=$(dokku_apps); local APP local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -z $2 ]]; then if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
for APP in $INSTALLED_APPS; do INFO_FLAG="$APP"
certs_report_single_app "$APP" "true" APP=""
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi
if [[ -z "$APP" ]]; then
for app in $INSTALLED_APPS; do
report_single_app "$app" "$INFO_FLAG" | tee || true
done done
else else
certs_report_single_app "$2" "$3" report_single_app "$APP" "$INFO_FLAG"
fi fi
} }

View File

@@ -19,8 +19,9 @@ fn-checks-skipped-list() {
echo "$DOKKU_CHECKS_SKIPPED" echo "$DOKKU_CHECKS_SKIPPED"
} }
checks_report_single_app() { report_single_app() {
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2" declare APP="$1" INFO_FLAG="$2"
local APP_DIR="$DOKKU_ROOT/$APP"
if [[ "$INFO_FLAG" == "true" ]]; then if [[ "$INFO_FLAG" == "true" ]]; then
INFO_FLAG="" INFO_FLAG=""
fi fi
@@ -61,14 +62,24 @@ checks_report_single_app() {
checks_report_cmd() { checks_report_cmd() {
declare desc="shows reports for an app" declare desc="shows reports for an app"
local cmd="checks:report" local cmd="checks:report"
local INSTALLED_APPS=$(dokku_apps); local APP local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -z $2 ]]; then if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
for APP in $INSTALLED_APPS; do INFO_FLAG="$APP"
checks_report_single_app "$APP" "true" APP=""
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi
if [[ -z "$APP" ]]; then
for app in $INSTALLED_APPS; do
report_single_app "$app" "$INFO_FLAG" | tee || true
done done
else else
checks_report_single_app "$2" "$3" report_single_app "$APP" "$INFO_FLAG"
fi fi
} }

View File

@@ -11,8 +11,9 @@ fn-docker-options() {
fi fi
} }
docker_options_report_single_app() { report_single_app() {
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2" declare APP="$1" INFO_FLAG="$2"
local APP_DIR="$DOKKU_ROOT/$APP"
if [[ "$INFO_FLAG" == "true" ]]; then if [[ "$INFO_FLAG" == "true" ]]; then
INFO_FLAG="" INFO_FLAG=""
fi fi
@@ -54,14 +55,24 @@ docker_options_report_single_app() {
docker_options_report_cmd() { docker_options_report_cmd() {
declare desc="displays a docker options report for one or more apps" declare desc="displays a docker options report for one or more apps"
local cmd="docker-options:report" local cmd="docker-options:report"
local INSTALLED_APPS=$(dokku_apps); local APP local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -z $2 ]]; then if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
for APP in $INSTALLED_APPS; do INFO_FLAG="$APP"
docker_options_report_single_app "$APP" "true" APP=""
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi
if [[ -z "$APP" ]]; then
for app in $INSTALLED_APPS; do
report_single_app "$app" "$INFO_FLAG" | tee || true
done done
else else
docker_options_report_single_app "$2" "$3" report_single_app "$APP" "$INFO_FLAG"
fi fi
} }

View File

@@ -34,8 +34,9 @@ fn-domains-global-vhosts() {
fi fi
} }
domains_report_single_app() { report_single_app() {
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2" declare APP="$1" INFO_FLAG="$2"
local APP_DIR="$DOKKU_ROOT/$APP"
if [[ "$INFO_FLAG" == "true" ]]; then if [[ "$INFO_FLAG" == "true" ]]; then
INFO_FLAG="" INFO_FLAG=""
fi fi
@@ -78,14 +79,24 @@ domains_report_single_app() {
domains_report_cmd() { domains_report_cmd() {
declare desc="displays a domains report for one or more apps" declare desc="displays a domains report for one or more apps"
local cmd="domains:report" local cmd="domains:report"
local INSTALLED_APPS=$(dokku_apps); local APP local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -z $2 ]]; then if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
for APP in $INSTALLED_APPS; do INFO_FLAG="$APP"
domains_report_single_app "$APP" "true" APP=""
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi
if [[ -z "$APP" ]]; then
for app in $INSTALLED_APPS; do
report_single_app "$app" "$INFO_FLAG" | tee || true
done done
else else
domains_report_single_app "$2" "$3" report_single_app "$APP" "$INFO_FLAG"
fi fi
} }

View File

@@ -13,8 +13,9 @@ fn-proxy-enabled() {
echo "$PROXY_ENABLED" echo "$PROXY_ENABLED"
} }
proxy_report_single_app() { report_single_app() {
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2" declare APP="$1" INFO_FLAG="$2"
local APP_DIR="$DOKKU_ROOT/$APP"
if [[ "$INFO_FLAG" == "true" ]]; then if [[ "$INFO_FLAG" == "true" ]]; then
INFO_FLAG="" INFO_FLAG=""
fi fi
@@ -56,14 +57,24 @@ proxy_report_single_app() {
proxy_report_cmd() { proxy_report_cmd() {
declare desc="displays a proxy report for one or more apps" declare desc="displays a proxy report for one or more apps"
local cmd="proxy:report" local cmd="proxy:report"
local INSTALLED_APPS=$(dokku_apps); local APP local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -z $2 ]]; then if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
for APP in $INSTALLED_APPS; do INFO_FLAG="$APP"
proxy_report_single_app "$APP" "true" APP=""
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi
if [[ -z "$APP" ]]; then
for app in $INSTALLED_APPS; do
report_single_app "$app" "$INFO_FLAG" | tee || true
done done
else else
proxy_report_single_app "$2" "$3" report_single_app "$APP" "$INFO_FLAG"
fi fi
} }

View File

@@ -4,8 +4,9 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions"
ps_report_single_app() { report_single_app() {
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2" declare APP="$1" INFO_FLAG="$2"
local APP_DIR="$DOKKU_ROOT/$APP"
local passed_phases="deploy" local passed_phases="deploy"
local APP_CIDS=$(get_app_container_ids "$APP"); local PROCS=0; local RUNNING="" local APP_CIDS=$(get_app_container_ids "$APP"); local PROCS=0; local RUNNING=""
@@ -90,14 +91,24 @@ ps_report_single_app() {
ps_report_cmd() { ps_report_cmd() {
declare desc="shows reports for an app" declare desc="shows reports for an app"
local cmd="ps:report" local cmd="ps:report"
local INSTALLED_APPS=$(dokku_apps); local APP local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -z $2 ]]; then if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
for APP in $INSTALLED_APPS; do INFO_FLAG="$APP"
ps_report_single_app "$APP" APP=""
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi
if [[ -z "$APP" ]]; then
for app in $INSTALLED_APPS; do
report_single_app "$app" "$INFO_FLAG" | tee || true
done done
else else
ps_report_single_app "$2" "$3" report_single_app "$APP" "$INFO_FLAG"
fi fi
} }

View File

@@ -11,8 +11,9 @@ fn-storage-bind-mounts() {
fi fi
} }
storage_report_single_app() { report_single_app() {
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2" declare APP="$1" INFO_FLAG="$2"
local APP_DIR="$DOKKU_ROOT/$APP"
if [[ "$INFO_FLAG" == "true" ]]; then if [[ "$INFO_FLAG" == "true" ]]; then
INFO_FLAG="" INFO_FLAG=""
fi fi
@@ -54,14 +55,24 @@ storage_report_single_app() {
storage_report_cmd() { storage_report_cmd() {
declare desc="displays a storage report for one or more apps" declare desc="displays a storage report for one or more apps"
local cmd="storage:report" local cmd="storage:report"
local INSTALLED_APPS=$(dokku_apps); local APP local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -z $2 ]]; then if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
for APP in $INSTALLED_APPS; do INFO_FLAG="$APP"
storage_report_single_app "$APP" "true" APP=""
fi
if [[ -z "$APP" ]] && [[ -z "$INFO_FLAG" ]]; then
INFO_FLAG="true"
fi
if [[ -z "$APP" ]]; then
for app in $INSTALLED_APPS; do
report_single_app "$app" "$INFO_FLAG" | tee || true
done done
else else
storage_report_single_app "$2" "$3" report_single_app "$APP" "$INFO_FLAG"
fi fi
} }