port --app syntax to dokku_client. closes #1638

This commit is contained in:
Michael Hobbs committed 2016-03-04 12:38:23 -08:00
1 parent 62731aa434
commit 4204d210c1
3 files changed
+45 -75

No files matched your search

+35 -72
View File
@@ -54,80 +54,43 @@ if [[ ! -z $DOKKU_HOST ]]; then
echo "This is not a git repository" echo "This is not a git repository"
fi fi
if [[ "$appname" != "" ]] && [[ -n "$*" ]]; then case "$1" in
case "$1" in apps:create)
apps|help|plugins*|ps:restartall|trace|version) if [[ -z "$2" ]]; then
true appname=$(random_name)
;; counter=0
apps:destroy) while ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do
if [[ -z "$2" ]] || [[ "$2" == "force" ]]; then if [[ $counter -ge 100 ]]; then
donotshift="YES" echo "Error: could not reasonably generate a new app name. try cleaning up some apps..."
fi ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps
;; exit 1
*) else
donotshift="YES" appname=$(random_name)
;; counter=$((counter+1))
esac fi
fi done
else
if [[ "$1" = "apps:create" ]]; then appname="$2"
if [[ -z "$2" ]]; then
appname=$(random_name)
counter=0
while ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do
if [[ $counter -ge 100 ]]; then
echo "Error: could not reasonably generate a new app name. try cleaning up some apps..."
ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps
exit 1
else
appname=$(random_name)
counter=$((counter+1))
fi
done
else
appname="$2"
fi
if git remote add dokku "dokku@$DOKKU_HOST:$appname"; then
echo "-----> Dokku remote added at $DOKKU_HOST"
echo "-----> Application name is $appname"
else
echo "! Dokku remote not added! Do you already have a dokku remote?"
return
fi
git push dokku master
return $?
fi
if [[ -z "$donotshift" ]]; then
# shellcheck disable=SC2029
ssh -o LogLevel=QUIET -p "$DOKKU_PORT" -t "dokku@$DOKKU_HOST" "$@"
exit $?
fi
if [[ -z "$verb" ]]; then
if [[ ! "$1" =~ --* ]]; then
verb=$1
shift
if [[ "$1" == "$appname" ]]; then
shift
fi fi
if git remote add dokku "dokku@$DOKKU_HOST:$appname"; then
echo "-----> Dokku remote added at $DOKKU_HOST"
echo "-----> Application name is $appname"
else
echo "! Dokku remote not added! Do you already have a dokku remote?"
return
fi
git push dokku master
return $?
;;
apps:destroy)
git remote remove dokku
;;
esac
args="$*" [[ -n "$@" ]] && [[ -n "$appname" ]] && app_arg="--app $appname"
else # echo "ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_HOST -- $app_arg $@"
long_args="--" # shellcheck disable=SC2068,SC2086
for arg in "$@"; do ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_HOST -- $app_arg $@
if [[ "$arg" =~ --* ]]; then
long_args+=" $arg"
args=("${args[@]/$arg}")
else
verb="$arg"
fi
done
fi
fi
# shellcheck disable=SC2086,SC2029
ssh -o LogLevel=QUIET -p "$DOKKU_PORT" -t "dokku@$DOKKU_HOST" $long_args "$verb" "$appname" "${args[@]}"
} }
if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]] || [[ "$0" == $(which dokku) ]]; then if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]] || [[ "$0" == $(which dokku) ]]; then
+8 -1
View File
@@ -113,7 +113,14 @@ execute_dokku_cmd() {
if [[ "$(readlink -f "$PLUGIN_ENABLED_PATH/${PLUGIN_NAME%%:*}")" == *core-plugins* ]] ; then if [[ "$(readlink -f "$PLUGIN_ENABLED_PATH/${PLUGIN_NAME%%:*}")" == *core-plugins* ]] ; then
[[ ${argv[0]} == "$PLUGIN_CMD" ]] && shift 1 [[ ${argv[0]} == "$PLUGIN_CMD" ]] && shift 1
[[ ! -z $DOKKU_APP_NAME ]] && set -- "$DOKKU_APP_NAME" "$@" if [[ ! -z $DOKKU_APP_NAME ]]; then
if [[ "$PLUGIN_CMD" == config* ]] && [[ ${argv[1]} == "--no-restart" ]]; then
shift 1
set -- "--no-restart" "$DOKKU_APP_NAME" "$@"
else
set -- "$DOKKU_APP_NAME" "$@"
fi
fi
set -- "$PLUGIN_CMD" "$@" set -- "$PLUGIN_CMD" "$@"
fi fi
+2 -2
View File
@@ -34,7 +34,7 @@ teardown() {
echo "status: "$status echo "status: "$status
assert_success assert_success
git remote | grep dokku git remote | grep dokku
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh --force apps:destroy" run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh apps:destroy --force"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
@@ -49,7 +49,7 @@ teardown() {
assert_success assert_success
git remote | grep dokku git remote | grep dokku
git remote -v | grep $test_app_name git remote -v | grep $test_app_name
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh --force apps:destroy" run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh apps:destroy --force"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success