Skip to content

Commit afdb755

Browse files
authored
backport owls-99865 to release/3.4 branch (#3202)
* validate that domainUID is a valid WebLogic domain name * add comment to validateDomainUid method * backport from main
1 parent ca47360 commit afdb755

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

kubernetes/samples/scripts/common/validate.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@ function validateLowerCase {
8282
fi
8383
}
8484

85+
#
86+
# Function to check if a value is a valid WLS domain name.
87+
# must include only alphanumeric characters, hyphens (-)
88+
# or underscore characters (_) and contain at least one letter
89+
# but must start with an alphanumeric or underscore character.
90+
#
91+
# $1 - name of object being checked
92+
# $2 - value to check
93+
validateWlsDomainName() {
94+
echo "validateWlsDomainName called with $2"
95+
if ! [[ "$2" =~ ^[a-z_][a-z0-9_.-]*$ ]] ; then
96+
validationError "$1 with value of $2 is not a valid WebLogic domain name. "\
97+
"A valid WebLogic domain name must include only alphanumeric characters, hyphens (-) "\
98+
"or underscore characters (_) but must start with an alphanumeric or underscore character."
99+
else
100+
if ! [[ "$2" =~ ^.*[a-z0-9].*$ ]] ; then
101+
validationError "$1 with value of $2 is not a valid WebLogic domain name. "\
102+
"A valid WebLogic domain name must contain at least one alphanumeric character."
103+
fi
104+
fi
105+
}
106+
85107
#
86108
# Function to check if a value is lowercase and legal DNS name
87109
# $1 - name of object being checked
@@ -112,10 +134,13 @@ function validateVersion {
112134

113135
#
114136
# Function to ensure the domain uid is a legal DNS name
137+
# Because the domain uid is also used as a WebLogic domain
138+
# name, it must also be a valid WebLogic domain name.
115139
#
116140
function validateDomainUid {
117-
validateLowerCase "domainUID" ${domainUID}
118-
validateDNS1123LegalName domainUID ${domainUID}
141+
validateLowerCase "domainUID" "${domainUID}"
142+
validateDNS1123LegalName "domainUID" "${domainUID}"
143+
validateWlsDomainName "domainUID" "${domainUID}"
119144
}
120145

121146
#

0 commit comments

Comments
 (0)