From 3419f18c9f383fb6b443e86b52729d19549289df Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 9 Jan 2021 07:40:45 -0500 Subject: [PATCH] fix: correct issue where verifying an app name would bail early Refs #4308 --- plugins/common/functions | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/plugins/common/functions b/plugins/common/functions index d18e2b2b6..f0d3f2a29 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -180,7 +180,7 @@ dokku_container_log_verbose_quiet() { IFS=$OIFS } -is_valid_app_name() { +fn-is-valid-app-name() { declare desc="verify that the app name matches naming restrictions" local APP="$1" [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" @@ -190,10 +190,10 @@ is_valid_app_name() { fi fi - dokku_log_fail "App name must begin with lowercase alphanumeric character, and cannot include uppercase characters, colons, or underscores" + return 1 } -is_valid_app_name_old() { +fn-is-valid-app-name-old() { declare desc="verify that the app name matches the old naming restrictions" local APP="$1" [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" @@ -203,6 +203,28 @@ is_valid_app_name_old() { fi fi + return 1 +} + +is_valid_app_name() { + declare desc="verify that the app name matches naming restrictions" + local APP="$1" + + if fn-is-valid-app-name "$APP"; then + return + fi + + dokku_log_fail "App name must begin with lowercase alphanumeric character, and cannot include uppercase characters, colons, or underscores" +} + +is_valid_app_name_old() { + declare desc="verify that the app name matches the old naming restrictions" + local APP="$1" + + if fn-is-valid-app-name-old "$APP"; then + return + fi + dokku_log_fail "App name must begin with lowercase alphanumeric character, and cannot include uppercase characters, or colons" } @@ -211,8 +233,13 @@ verify_app_name() { declare APP="$1" local VALID_NEW=false local VALID_OLD=false - is_valid_app_name "$APP" 2>/dev/null && VALID_NEW=true - is_valid_app_name_old "$APP" 2>/dev/null && VALID_OLD=true + if fn-is-valid-app-name "$APP" 2>/dev/null; then + VALID_NEW=true + fi + + if fn-is-valid-app-name-old "$APP" 2>/dev/null; then + VALID_OLD=true + fi if [[ "$VALID_NEW" == "false" ]] && [[ "$VALID_OLD" == "false" ]]; then dokku_log_fail "App name must begin with lowercase alphanumeric character, and cannot include uppercase characters, colons, or underscores"