From 876ff0c330d1997ffbc06b72fb81845b1eec0076 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 8 Mar 2019 23:49:25 -0500 Subject: [PATCH 1/3] chore: minor consolidation in functions files --- functions | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions b/functions index c102606..22d4da7 100755 --- a/functions +++ b/functions @@ -8,8 +8,6 @@ if [[ -f "$PLUGIN_AVAILABLE_PATH/docker-options/functions" ]]; then source "$PLUGIN_AVAILABLE_PATH/docker-options/functions" fi -# non-generic functions - service_connect() { local SERVICE="$1" local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" @@ -42,6 +40,8 @@ service_create() { mkdir -p "$SERVICE_ROOT" || dokku_log_fail "Unable to create service directory" mkdir -p "$SERVICE_ROOT/data" || dokku_log_fail "Unable to create service data directory" mkdir -p "$SERVICE_ROOT/config" || dokku_log_fail "Unable to create service config directory" + touch "$LINKS_FILE" + if [[ -z $REDIS_CONFIG_PATH ]] ; then curl -sSL "https://raw.githubusercontent.com/antirez/redis/${PLUGIN_IMAGE_VERSION:0:3}/redis.conf" > "$SERVICE_ROOT/config/redis.conf" || dokku_log_fail "Unable to download the default redis.conf to the config directory" else @@ -55,7 +55,6 @@ service_create() { echo "$PASSWORD" > "$SERVICE_ROOT/PASSWORD" chmod 640 "$SERVICE_ROOT/PASSWORD" sed -i.bak "s/# requirepass.*/requirepass ${PASSWORD}/" "$SERVICE_ROOT/config/redis.conf" && rm "$SERVICE_ROOT/config/redis.conf.bak" - touch "$LINKS_FILE" [[ -n "$SERVICE_CUSTOM_ENV" ]] && REDIS_CUSTOM_ENV="$SERVICE_CUSTOM_ENV" if [[ -n $REDIS_CUSTOM_ENV ]]; then From 35d5e9cab4731e03846163bbd9969c68577d3e5b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 9 Mar 2019 00:17:30 -0500 Subject: [PATCH 2/3] fix: Strictly validate service names We previously allowed a wide range of service names. As the service name is sometimes used to name databases, the name was actually more restricted than any character, resulting in services that wouldn't start. Going forward, only alphanumeric and underscore characters are allowed. This only impacts service creation. Any services with invalid names should be migrated to a new service, with the data exported and imported as normal. Closes dokku/dokku-redis#99 Closes dokku/dokku-mysql#47 Closes dokku/dokku-mongo#86 Closes dokku/dokku-redis#81 --- common-functions | 12 ++++++++++++ functions | 1 + tests/service_create.bats | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/common-functions b/common-functions index 697fcd7..d215074 100755 --- a/common-functions +++ b/common-functions @@ -731,3 +731,15 @@ verify_service_name() { [[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] && dokku_log_fail "$PLUGIN_SERVICE service $SERVICE does not exist" return 0 } + +is_valid_service_name() { + declare desc="Validates a service name" + declare SERVICE="$1" + [[ -z "$SERVICE" ]] && dokku_log_fail "SERVICE must not be null" + + if [[ "$SERVICE" =~ ^[A-Za-z0-9_]+$ ]]; then + return 0 + fi + + return 1 +} diff --git a/functions b/functions index 22d4da7..1c5698b 100755 --- a/functions +++ b/functions @@ -21,6 +21,7 @@ service_connect() { service_create() { local SERVICE="$1" + is_valid_service_name "$SERVICE" || dokku_log_fail "Please specify a valid name for the service. Valid characters are: [A-Za-z0-9_]+" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" [[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] || dokku_log_fail "$PLUGIN_SERVICE service $SERVICE already exists" SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS" diff --git a/tests/service_create.bats b/tests/service_create.bats index 7ecb87b..777441d 100755 --- a/tests/service_create.bats +++ b/tests/service_create.bats @@ -10,3 +10,11 @@ load test_helper run dokku "$PLUGIN_COMMAND_PREFIX:create" assert_contains "${lines[*]}" "Please specify a name for the service" } + +@test "($PLUGIN_COMMAND_PREFIX:create) error when there is an invalid name specified" { + run dokku "$PLUGIN_COMMAND_PREFIX:create" d.erp + assert_failure + + run dokku "$PLUGIN_COMMAND_PREFIX:create" d-erp + assert_failure +} From 7ce772224acbf9d9c583518e62a6189c72a6c0ad Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 9 Mar 2019 16:39:35 -0500 Subject: [PATCH 3/3] fix: correct the validation message --- common-functions | 2 +- functions | 2 +- subcommands/backup | 2 +- subcommands/backup-auth | 2 +- subcommands/backup-deauth | 2 +- subcommands/backup-schedule | 2 +- subcommands/backup-schedule-cat | 2 +- subcommands/backup-set-encryption | 2 +- subcommands/backup-unschedule | 2 +- subcommands/backup-unset-encryption | 2 +- subcommands/clone | 2 +- subcommands/connect | 2 +- subcommands/destroy | 2 +- subcommands/exists | 2 +- subcommands/export | 2 +- subcommands/expose | 2 +- subcommands/import | 2 +- subcommands/info | 2 +- subcommands/link | 2 +- subcommands/linked | 2 +- subcommands/logs | 2 +- subcommands/promote | 2 +- subcommands/restart | 2 +- subcommands/start | 2 +- subcommands/stop | 2 +- subcommands/unexpose | 2 +- subcommands/unlink | 2 +- subcommands/upgrade | 2 +- tests/service_clone.bats | 2 +- tests/service_connect.bats | 2 +- tests/service_create.bats | 2 +- tests/service_destroy.bats | 2 +- tests/service_export.bats | 2 +- tests/service_expose.bats | 2 +- tests/service_import.bats | 2 +- tests/service_info.bats | 2 +- tests/service_link.bats | 2 +- tests/service_logs.bats | 2 +- tests/service_promote.bats | 2 +- tests/service_restart.bats | 2 +- tests/service_start.bats | 2 +- tests/service_stop.bats | 2 +- tests/service_unexpose.bats | 2 +- tests/service_unlink.bats | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) diff --git a/common-functions b/common-functions index d215074..adfec90 100755 --- a/common-functions +++ b/common-functions @@ -735,7 +735,7 @@ verify_service_name() { is_valid_service_name() { declare desc="Validates a service name" declare SERVICE="$1" - [[ -z "$SERVICE" ]] && dokku_log_fail "SERVICE must not be null" + [[ -z "$SERVICE" ]] && return 1 if [[ "$SERVICE" =~ ^[A-Za-z0-9_]+$ ]]; then return 0 diff --git a/functions b/functions index 1c5698b..ce5ef8a 100755 --- a/functions +++ b/functions @@ -22,7 +22,7 @@ service_connect() { service_create() { local SERVICE="$1" is_valid_service_name "$SERVICE" || dokku_log_fail "Please specify a valid name for the service. Valid characters are: [A-Za-z0-9_]+" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] || dokku_log_fail "$PLUGIN_SERVICE service $SERVICE already exists" SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS" diff --git a/subcommands/backup b/subcommands/backup index ff52626..a22b976 100755 --- a/subcommands/backup +++ b/subcommands/backup @@ -15,7 +15,7 @@ service-backup-cmd() { declare SERVICE="$1" BUCKET_NAME="$2" USE_IAM_OPTIONAL_FLAG="$3" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$BUCKET_NAME" ]] && dokku_log_fail "Please specify an aws bucket for the backup" verify_service_name "$SERVICE" service_backup "$SERVICE" "$BUCKET_NAME" "$USE_IAM_OPTIONAL_FLAG" diff --git a/subcommands/backup-auth b/subcommands/backup-auth index 3bf97a1..5c528bb 100755 --- a/subcommands/backup-auth +++ b/subcommands/backup-auth @@ -24,7 +24,7 @@ service-backup-auth-cmd() { declare SERVICE="$1" AWS_ACCESS_KEY_ID="$2" AWS_SECRET_ACCESS_KEY="$3" AWS_DEFAULT_REGION="$4" AWS_SIGNATURE_VERSION="$5" ENDPOINT_URL="$6" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$AWS_ACCESS_KEY_ID" ]] && dokku_log_fail "Please specify an aws access key id" [[ -z "$AWS_SECRET_ACCESS_KEY" ]] && dokku_log_fail "Please specify an aws secret access key" verify_service_name "$SERVICE" diff --git a/subcommands/backup-deauth b/subcommands/backup-deauth index a8f3fac..9d01e9c 100755 --- a/subcommands/backup-deauth +++ b/subcommands/backup-deauth @@ -13,7 +13,7 @@ service-backup-deauth-cmd() { declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_backup_deauth "$SERVICE" } diff --git a/subcommands/backup-schedule b/subcommands/backup-schedule index a95c478..8802da7 100755 --- a/subcommands/backup-schedule +++ b/subcommands/backup-schedule @@ -19,7 +19,7 @@ service-backup-schedule-cmd() { declare SERVICE="$1" SCHEDULE="$2" BUCKET_NAME="$3" USE_IAM_OPTIONAL_FLAG="$4" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$SCHEDULE" ]] && dokku_log_fail "Please specify a schedule for the backup" [[ -z "$BUCKET_NAME" ]] && dokku_log_fail "Please specify an aws bucket for the backup" verify_service_name "$SERVICE" diff --git a/subcommands/backup-schedule-cat b/subcommands/backup-schedule-cat index 3cfd326..7607991 100755 --- a/subcommands/backup-schedule-cat +++ b/subcommands/backup-schedule-cat @@ -12,7 +12,7 @@ service-backup-schedule-cat-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:backup-schedule-cat" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_backup_schedule_cat "$SERVICE" } diff --git a/subcommands/backup-set-encryption b/subcommands/backup-set-encryption index dce3620..0e18de0 100755 --- a/subcommands/backup-set-encryption +++ b/subcommands/backup-set-encryption @@ -14,7 +14,7 @@ service-backup-set-encryption-cmd() { declare SERVICE="$1" PASSPHRASE="$2" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$PASSPHRASE" ]] && dokku_log_fail "Please specify a GPG backup passphrase" verify_service_name "$SERVICE" service_backup_set_encryption "$SERVICE" "$PASSPHRASE" diff --git a/subcommands/backup-unschedule b/subcommands/backup-unschedule index 73d902b..b305901 100755 --- a/subcommands/backup-unschedule +++ b/subcommands/backup-unschedule @@ -13,7 +13,7 @@ service-backup-unschedule-cmd() { declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_backup_unschedule "$SERVICE" } diff --git a/subcommands/backup-unset-encryption b/subcommands/backup-unset-encryption index 619772c..acd4b4c 100755 --- a/subcommands/backup-unset-encryption +++ b/subcommands/backup-unset-encryption @@ -13,7 +13,7 @@ service-backup-unset-encryption-cmd() { declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_backup_unset_encryption "$SERVICE" } diff --git a/subcommands/clone b/subcommands/clone index ab0e073..bc8fe48 100755 --- a/subcommands/clone +++ b/subcommands/clone @@ -19,7 +19,7 @@ service-clone-cmd() { declare SERVICE="$1" NEW_SERVICE="$2" CLONE_FLAGS_LIST="${@:3}" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$NEW_SERVICE" ]] && dokku_log_fail "Please specify a name for the new service" verify_service_name "$SERVICE" diff --git a/subcommands/connect b/subcommands/connect index 10bf500..0746db4 100755 --- a/subcommands/connect +++ b/subcommands/connect @@ -13,7 +13,7 @@ service-connect-cmd() { declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_connect "$SERVICE" } diff --git a/subcommands/destroy b/subcommands/destroy index e25938b..713bf60 100755 --- a/subcommands/destroy +++ b/subcommands/destroy @@ -13,7 +13,7 @@ service-destroy-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:destroy" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" FORCE_FLAG="$2" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS" SERVICE_HOST_ROOT="$PLUGIN_DATA_HOST_ROOT/$SERVICE" diff --git a/subcommands/exists b/subcommands/exists index 93b6a99..457aa27 100755 --- a/subcommands/exists +++ b/subcommands/exists @@ -12,7 +12,7 @@ service-exists-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:exists" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" dokku_log_info1 "Service $SERVICE exists" } diff --git a/subcommands/export b/subcommands/export index 84ebec3..d63e95b 100755 --- a/subcommands/export +++ b/subcommands/export @@ -15,7 +15,7 @@ service-export-cmd() { declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_export "$SERVICE" } diff --git a/subcommands/expose b/subcommands/expose index 70ac6eb..bcee26c 100755 --- a/subcommands/expose +++ b/subcommands/expose @@ -13,7 +13,7 @@ service-expose-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:expose" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" PORTS_LIST="${@:2}" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_port_expose "$SERVICE" "${@:2}" } diff --git a/subcommands/import b/subcommands/import index 28f85d9..1239c4f 100755 --- a/subcommands/import +++ b/subcommands/import @@ -13,7 +13,7 @@ service-import-cmd() { declare SERVICE="$1" is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_import "$SERVICE" } diff --git a/subcommands/info b/subcommands/info index e76da83..d1dd6aa 100755 --- a/subcommands/info +++ b/subcommands/info @@ -33,7 +33,7 @@ service-info-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:info" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" INFO_FLAG="$2" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_info "$SERVICE" "$INFO_FLAG" } diff --git a/subcommands/link b/subcommands/link index 4f94498..f3f276d 100755 --- a/subcommands/link +++ b/subcommands/link @@ -46,7 +46,7 @@ service-link-cmd() { declare SERVICE="$1" APP="$2" LINK_FLAGS_LIST="${@:3}" APP=${APP:="$DOKKU_APP_NAME"} - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$APP" verify_service_name "$SERVICE" diff --git a/subcommands/linked b/subcommands/linked index f5a1789..1fd94ab 100755 --- a/subcommands/linked +++ b/subcommands/linked @@ -14,7 +14,7 @@ service-linked-cmd() { declare SERVICE="$1" APP="$2" APP=${APP:="$DOKKU_APP_NAME"} - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_app_name "$APP" verify_service_name "$SERVICE" diff --git a/subcommands/logs b/subcommands/logs index 01920bc..efa9f08 100755 --- a/subcommands/logs +++ b/subcommands/logs @@ -15,7 +15,7 @@ service-logs-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:logs" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" TAIL_FLAG="$2" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_logs "$SERVICE" "$TAIL_FLAG" } diff --git a/subcommands/promote b/subcommands/promote index d9167c0..06d0b37 100755 --- a/subcommands/promote +++ b/subcommands/promote @@ -27,7 +27,7 @@ service-promote-cmd() { declare SERVICE="$1" APP="$2" APP=${APP:="$DOKKU_APP_NAME"} - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_service_name "$SERVICE" verify_app_name "$APP" diff --git a/subcommands/restart b/subcommands/restart index 315a4be..b6d5dae 100755 --- a/subcommands/restart +++ b/subcommands/restart @@ -12,7 +12,7 @@ service-restart-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:restart" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_stop "$SERVICE" service_start "$SERVICE" diff --git a/subcommands/start b/subcommands/start index 1db1e40..47fc913 100755 --- a/subcommands/start +++ b/subcommands/start @@ -12,7 +12,7 @@ service-start-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:start" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_start "$SERVICE" } diff --git a/subcommands/stop b/subcommands/stop index 77e52f4..59b98cc 100755 --- a/subcommands/stop +++ b/subcommands/stop @@ -12,7 +12,7 @@ service-stop-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:stop" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_stop "$SERVICE" } diff --git a/subcommands/unexpose b/subcommands/unexpose index 289d164..c821842 100755 --- a/subcommands/unexpose +++ b/subcommands/unexpose @@ -12,7 +12,7 @@ service-unexpose-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:unexpose" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" service_port_unexpose "$SERVICE" } diff --git a/subcommands/unlink b/subcommands/unlink index a58e9c7..487ecc1 100755 --- a/subcommands/unlink +++ b/subcommands/unlink @@ -15,7 +15,7 @@ service-unlink-cmd() { declare SERVICE="$1" APP="$2" APP=${APP:="$DOKKU_APP_NAME"} - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" verify_service_name "$SERVICE" verify_app_name "$APP" diff --git a/subcommands/upgrade b/subcommands/upgrade index 76f1a9b..800b15e 100755 --- a/subcommands/upgrade +++ b/subcommands/upgrade @@ -17,7 +17,7 @@ service-upgrade-cmd() { local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" UPGRADE_FLAGS_LIST="${@:2}" - [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" + [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" diff --git a/tests/service_clone.bats b/tests/service_clone.bats index 658eb24..118d2a9 100755 --- a/tests/service_clone.bats +++ b/tests/service_clone.bats @@ -13,7 +13,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:clone) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:clone" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:clone) error when service does not exist" { diff --git a/tests/service_connect.bats b/tests/service_connect.bats index a6fd2aa..6baeb86 100755 --- a/tests/service_connect.bats +++ b/tests/service_connect.bats @@ -13,7 +13,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:connect) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:connect" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:connect) error when service does not exist" { diff --git a/tests/service_create.bats b/tests/service_create.bats index 777441d..8d452e5 100755 --- a/tests/service_create.bats +++ b/tests/service_create.bats @@ -8,7 +8,7 @@ load test_helper @test "($PLUGIN_COMMAND_PREFIX:create) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:create" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:create) error when there is an invalid name specified" { diff --git a/tests/service_destroy.bats b/tests/service_destroy.bats index 03f23c3..654e260 100755 --- a/tests/service_destroy.bats +++ b/tests/service_destroy.bats @@ -9,7 +9,7 @@ load test_helper @test "($PLUGIN_COMMAND_PREFIX:destroy) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:destroy" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:destroy) error when container does not exist" { diff --git a/tests/service_export.bats b/tests/service_export.bats index b09e492..6e20a83 100755 --- a/tests/service_export.bats +++ b/tests/service_export.bats @@ -13,7 +13,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:export) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:export" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:export) error when service does not exist" { diff --git a/tests/service_expose.bats b/tests/service_expose.bats index c24e761..2362d80 100755 --- a/tests/service_expose.bats +++ b/tests/service_expose.bats @@ -11,7 +11,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:expose) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:expose" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:expose) error when service does not exist" { diff --git a/tests/service_import.bats b/tests/service_import.bats index 49a79f3..0c66b0d 100755 --- a/tests/service_import.bats +++ b/tests/service_import.bats @@ -15,7 +15,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:import) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:import" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:import) error when service does not exist" { diff --git a/tests/service_info.bats b/tests/service_info.bats index fd1aa5e..b0b2ffc 100755 --- a/tests/service_info.bats +++ b/tests/service_info.bats @@ -11,7 +11,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:info) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:info" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:info) error when service does not exist" { diff --git a/tests/service_link.bats b/tests/service_link.bats index 02079e8..4ed200a 100755 --- a/tests/service_link.bats +++ b/tests/service_link.bats @@ -13,7 +13,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:link) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:link" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:link) error when the app argument is missing" { diff --git a/tests/service_logs.bats b/tests/service_logs.bats index eda210c..055cd1c 100755 --- a/tests/service_logs.bats +++ b/tests/service_logs.bats @@ -13,7 +13,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:logs) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:logs" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:logs) error when service does not exist" { diff --git a/tests/service_promote.bats b/tests/service_promote.bats index 7cd94ae..8e4cbdd 100755 --- a/tests/service_promote.bats +++ b/tests/service_promote.bats @@ -15,7 +15,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:promote) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:promote" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:promote) error when the app argument is missing" { diff --git a/tests/service_restart.bats b/tests/service_restart.bats index ab20d29..e97729d 100755 --- a/tests/service_restart.bats +++ b/tests/service_restart.bats @@ -11,7 +11,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:restart) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:restart" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:restart) error when service does not exist" { diff --git a/tests/service_start.bats b/tests/service_start.bats index 69a0852..9b7cae9 100755 --- a/tests/service_start.bats +++ b/tests/service_start.bats @@ -11,7 +11,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:start) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:start" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:start) error when service does not exist" { diff --git a/tests/service_stop.bats b/tests/service_stop.bats index 4b2f71b..95d5647 100755 --- a/tests/service_stop.bats +++ b/tests/service_stop.bats @@ -11,7 +11,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:stop) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:stop" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:stop) error when service does not exist" { diff --git a/tests/service_unexpose.bats b/tests/service_unexpose.bats index 02f0b8f..30153fd 100755 --- a/tests/service_unexpose.bats +++ b/tests/service_unexpose.bats @@ -11,7 +11,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:unexpose) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:unexpose" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:unexpose) error when service does not exist" { diff --git a/tests/service_unlink.bats b/tests/service_unlink.bats index c0c419c..dd1cc27 100755 --- a/tests/service_unlink.bats +++ b/tests/service_unlink.bats @@ -13,7 +13,7 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:unlink) error when there are no arguments" { run dokku "$PLUGIN_COMMAND_PREFIX:unlink" - assert_contains "${lines[*]}" "Please specify a name for the service" + assert_contains "${lines[*]}" "Please specify a valid name for the service" } @test "($PLUGIN_COMMAND_PREFIX:unlink) error when the app argument is missing" {