@@ -20,14 +20,12 @@ source ${scriptDir}/../../common/utility.sh
20
20
source ${scriptDir} /../../common/validate.sh
21
21
22
22
function usage {
23
- echo usage: ${script} -o dir -i file -u username -p password [-k] [- e] [-h]
23
+ echo usage: ${script} -o dir -i file -u username -p password [-e] [-h]
24
24
echo " -i Parameter inputs file, must be specified."
25
25
echo " -o Ouput directory for the generated properties and YAML files, must be specified."
26
26
echo " -u Username used in building the Docker image for WebLogic domain in image."
27
27
echo " -p Password used in building the Docker image for WebLogic domain in image."
28
28
echo " -e Also create the resources in the generated YAML files, optional."
29
- echo " -k Keep what has been previously from cloned https://github.com/oracle/docker-images.git, optional. "
30
- echo " If not specified, this script will always remove existing project directory and clone again."
31
29
echo " -h Help"
32
30
exit $1
33
31
}
@@ -36,8 +34,7 @@ function usage {
36
34
# Parse the command line options
37
35
#
38
36
executeIt=false
39
- cloneIt=true
40
- while getopts " evhki:o:u:p:" opt; do
37
+ while getopts " evhi:o:u:p:" opt; do
41
38
case $opt in
42
39
i) valuesInputFile=" ${OPTARG} "
43
40
;;
@@ -49,8 +46,6 @@ while getopts "evhki:o:u:p:" opt; do
49
46
;;
50
47
p) password=" ${OPTARG} "
51
48
;;
52
- k) cloneIt=false;
53
- ;;
54
49
h) usage 0
55
50
;;
56
51
* ) usage 1
86
81
# Function to initialize and validate the output directory
87
82
# for the generated properties and yaml files for this domain.
88
83
#
89
- function initOutputDir {
84
+ function initAndValidateOutputDir {
90
85
domainOutputDir=" ${outputDir} /weblogic-domains/${domainUID} "
91
86
# Create a directory for this domain's output files
92
87
mkdir -p ${domainOutputDir}
93
88
94
- removeFileIfExists ${domainOutputDir} /${valuesInputFile}
95
- removeFileIfExists ${domainOutputDir} /create-domain-inputs.yaml
96
- removeFileIfExists ${domainOutputDir} /domain.properties
97
- removeFileIfExists ${domainOutputDir} /domain.yaml
89
+ validateOutputDir \
90
+ ${domainOutputDir} \
91
+ ${valuesInputFile} \
92
+ create-domain-inputs.yaml \
93
+ domain.properties \
94
+ domain.yaml
95
+ }
96
+
97
+ #
98
+ # Function to validate the domain secret
99
+ #
100
+ function validateDomainSecret {
101
+ # Verify the secret exists
102
+ validateSecretExists ${weblogicCredentialsSecretName} ${namespace}
103
+ failIfValidationErrors
104
+
105
+ # Verify the secret contains a username
106
+ SECRET=` kubectl get secret ${weblogicCredentialsSecretName} -n ${namespace} -o jsonpath=' {.data}' | grep username: | wc | awk ' { print $1; }' `
107
+ if [ " ${SECRET} " != " 1" ]; then
108
+ validationError " The domain secret ${weblogicCredentialsSecretName} in namespace ${namespace} does contain a username"
109
+ fi
110
+
111
+ # Verify the secret contains a password
112
+ SECRET=` kubectl get secret ${weblogicCredentialsSecretName} -n ${namespace} -o jsonpath=' {.data}' | grep password: | wc | awk ' { print $1; }' `
113
+ if [ " ${SECRET} " != " 1" ]; then
114
+ validationError " The domain secret ${weblogicCredentialsSecretName} in namespace ${namespace} does contain a password"
115
+ fi
116
+ failIfValidationErrors
117
+ }
118
+
119
+ #
120
+ # Function to validate a kubernetes secret exists
121
+ # $1 - the name of the secret
122
+ # $2 - namespace
123
+ function validateSecretExists {
124
+ echo " Checking to see if the secret ${1} exists in namespace ${2} "
125
+ local SECRET=` kubectl get secret ${1} -n ${2} | grep ${1} | wc | awk ' { print $1; }' `
126
+ if [ " ${SECRET} " != " 1" ]; then
127
+ validationError " The secret ${1} was not found in namespace ${2} "
128
+ fi
98
129
}
99
130
100
131
# try to execute docker to see whether docker is available
@@ -139,20 +170,54 @@ function initialize {
139
170
140
171
failIfValidationErrors
141
172
142
- validateCommonInputs
143
-
144
- initOutputDir
173
+ # Parse the commonn inputs file
174
+ parseCommonInputs
175
+
176
+ validateInputParamsSpecified \
177
+ adminServerName \
178
+ domainUID \
179
+ clusterName \
180
+ managedServerNameBase \
181
+ namespace \
182
+ t3PublicAddress \
183
+ version
184
+
185
+ validateIntegerInputParamsSpecified \
186
+ adminPort \
187
+ configuredManagedServerCount \
188
+ initialManagedServerReplicas \
189
+ managedServerPort \
190
+ t3ChannelPort \
191
+ adminNodePort
192
+
193
+ validateBooleanInputParamsSpecified \
194
+ productionModeEnabled \
195
+ exposeAdminT3Channel \
196
+ exposeAdminNodePort \
197
+ includeServerOutInPodLog
198
+
199
+ export requiredInputsVersion=" create-weblogic-sample-domain-inputs-v1"
200
+ validateVersion
201
+
202
+ validateDomainUid
203
+ validateNamespace
204
+ validateAdminServerName
205
+ validateManagedServerNameBase
206
+ validateClusterName
207
+ validateWeblogicCredentialsSecretName
208
+ initAndValidateOutputDir
209
+ validateServerStartPolicy
210
+ validateClusterType
211
+ failIfValidationErrors
145
212
146
- if [ " ${cloneIt} " = true ]; then
147
- getDockerSample
148
- fi
213
+ getDockerSample
149
214
}
150
215
151
216
#
152
217
# Function to get the dependency docker sample
153
218
#
154
219
function getDockerSample {
155
- rm -rf $ {scriptDir} /docker-images
220
+ rm -rf {scriptDir}/docker-images
156
221
git clone https://github.com/oracle/docker-images.git
157
222
}
158
223
@@ -239,49 +304,14 @@ function createFiles {
239
304
# Function to build docker image and create WebLogic domain home
240
305
#
241
306
function createDomainHome {
242
- if [ -z $imagePath ]; then
243
- imagePath=" 12213-domain-home-in-image-wdt"
244
- fi
245
-
246
- cp ${domainPropertiesOutput} ./docker-images/OracleWebLogic/samples/${imagePath} /properties/docker_build
307
+ cp ${domainPropertiesOutput} ./docker-images/OracleWebLogic/samples/12213-domain-home-in-image/properties/docker_build
247
308
248
- imageName=" 12213-domain-home-in-image:latest"
249
- # use the existence of build-archive.sh file to determine if we need to download WDT
250
- if [ -f " ./docker-images/OracleWebLogic/samples/${imagePath} /build-archive.sh" ]; then
251
- imageName=" 12213-domain-wdt:latest"
252
- fi
309
+ cd docker-images/OracleWebLogic/samples/12213-domain-home-in-image
253
310
254
- # now we know which image to use, update the domain yaml file
255
- sed -i -e " s|%IMAGE_NAME% |${imageName } |g" ${dcrOutput}
311
+ sed -i -e " s|myuser| ${username} |g " properties/docker_build/domain_security.properties
312
+ sed -i -e " s|mypassword1 |${password } |g" properties/docker_build/domain_security.properties
256
313
257
- cd docker-images/OracleWebLogic/samples/${imagePath}
258
-
259
- # 12213-domain-home-in-image use one properties file for the credentials
260
- usernameFile=" properties/docker_build/domain_security.properties"
261
- passwordFile=" properties/docker_build/domain_security.properties"
262
-
263
- # 12213-domain-home-in-image-wdt uses two properties files for the credentials
264
- if [ ! -f $usernameFile ]; then
265
- usernameFile=" properties/docker-build/adminuser.properties"
266
- passwordFile=" properties/docker-build/adminpass.properties"
267
- sed -i -e " s|weblogic|${username} |g" $usernameFile
268
- sed -i -e " s|welcome1|${password} |g" $passwordFile
269
- else
270
- sed -i -e " s|myuser|${username} |g" $usernameFile
271
- sed -i -e " s|mypassword1|${password} |g" $passwordFile
272
- fi
273
-
274
- # use the existence of build-archive.sh file to determine if we need to download WDT
275
- if [ -f " build-archive.sh" ]; then
276
- sh ./build-archive.sh
277
- wget https://github.com/oracle/weblogic-deploy-tooling/releases/download/weblogic-deploy-tooling-0.14/weblogic-deploy.zip
278
- fi
279
-
280
- if [ ! -z $baseImage ]; then
281
- sed -i -e " s|\(FROM \).*|\1 ${baseImage} |g" Dockerfile
282
- fi
283
-
284
- sh ./build.sh
314
+ ./build.sh
285
315
286
316
if [ " $? " != " 0" ]; then
287
317
fail " Create domain ${domainName} failed."
@@ -313,10 +343,43 @@ function printSummary {
313
343
echo " ${domainOutputDir} /create-domain-inputs.yaml"
314
344
echo " ${domainPropertiesOutput} "
315
345
echo " ${dcrOutput} "
316
- echo " "
317
- echo " Completed"
318
346
}
319
347
320
- # Perform the sequence of steps to create a domain
321
- createDomain
348
+ #
349
+ # Function to create the domain resource
350
+ #
351
+ function createDomainResource {
352
+ pwd
353
+ kubectl apply -f ${dcrOutput}
354
+ DCR_AVAIL=` kubectl get domain -n ${namespace} | grep ${domainUID} | wc | awk ' { print $1; } ' `
355
+ if [ " ${DCR_AVAIL} " != " 1" ]; then
356
+ fail " The domain resource ${domainUID} was not found"
357
+ fi
358
+ }
359
+
360
+ #
361
+ # Perform the following sequence of steps to create a domain
362
+ #
363
+
364
+ # Setup the environment for running this script and perform initial validation checks
365
+ initialize
366
+
367
+ # Generate the properties and yaml files for creating the domain
368
+ createFiles
369
+
370
+ # Check that the domain secret exists and contains the required elements
371
+ validateDomainSecret
372
+
373
+ # Create the WebLogic domain
374
+ createDomainHome
375
+
376
+ if [ " ${executeIt} " = true ]; then
377
+ createDomainResource
378
+ fi
379
+
380
+ # Print a summary
381
+ printSummary
382
+
383
+ echo
384
+ echo Completed
322
385
0 commit comments