Merge pull request #4309 from dokku/4308-app-name-validation

Correct issue where verifying an app name would bail early
This commit is contained in:
Jose Diaz-Gonzalez authored and GitHub committed 2021-01-09 14:28:40 -05:00
commit bdd7c58a62
1 file changed
+32 -5
+32 -5
View File
@@ -180,7 +180,7 @@ dokku_container_log_verbose_quiet() {
IFS=$OIFS IFS=$OIFS
} }
is_valid_app_name() { fn-is-valid-app-name() {
declare desc="verify that the app name matches naming restrictions" declare desc="verify that the app name matches naming restrictions"
local APP="$1" local APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
@@ -190,10 +190,10 @@ is_valid_app_name() {
fi fi
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" declare desc="verify that the app name matches the old naming restrictions"
local APP="$1" local APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on" [[ -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
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" 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" declare APP="$1"
local VALID_NEW=false local VALID_NEW=false
local VALID_OLD=false local VALID_OLD=false
is_valid_app_name "$APP" 2>/dev/null && VALID_NEW=true if fn-is-valid-app-name "$APP" 2>/dev/null; then
is_valid_app_name_old "$APP" 2>/dev/null && VALID_OLD=true 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 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" dokku_log_fail "App name must begin with lowercase alphanumeric character, and cannot include uppercase characters, colons, or underscores"