diff --git a/kubernetes/samples/scripts/common/validate.sh b/kubernetes/samples/scripts/common/validate.sh index 1a407a99a82..b6f06337c80 100755 --- a/kubernetes/samples/scripts/common/validate.sh +++ b/kubernetes/samples/scripts/common/validate.sh @@ -82,6 +82,28 @@ function validateLowerCase { fi } +# +# Function to check if a value is a valid WLS domain name. +# must include only alphanumeric characters, hyphens (-) +# or underscore characters (_) and contain at least one letter +# but must start with an alphanumeric or underscore character. +# +# $1 - name of object being checked +# $2 - value to check +validateWlsDomainName() { + echo "validateWlsDomainName called with $2" + if ! [[ "$2" =~ ^[a-z_][a-z0-9_.-]*$ ]] ; then + validationError "$1 with value of $2 is not a valid WebLogic domain name. "\ + "A valid WebLogic domain name must include only alphanumeric characters, hyphens (-) "\ + "or underscore characters (_) but must start with an alphanumeric or underscore character." + else + if ! [[ "$2" =~ ^.*[a-z0-9].*$ ]] ; then + validationError "$1 with value of $2 is not a valid WebLogic domain name. "\ + "A valid WebLogic domain name must contain at least one alphanumeric character." + fi + fi +} + # # Function to check if a value is lowercase and legal DNS name # $1 - name of object being checked @@ -112,10 +134,13 @@ function validateVersion { # # Function to ensure the domain uid is a legal DNS name +# Because the domain uid is also used as a WebLogic domain +# name, it must also be a valid WebLogic domain name. # function validateDomainUid { - validateLowerCase "domainUID" ${domainUID} - validateDNS1123LegalName domainUID ${domainUID} + validateLowerCase "domainUID" "${domainUID}" + validateDNS1123LegalName "domainUID" "${domainUID}" + validateWlsDomainName "domainUID" "${domainUID}" } #