Skip to content

Commit fda0686

Browse files
authored
Check fileext wdt (#1592)
* add check for wdt version and file extensions in model directories * fix script errors * fix script error * update error wordings * fix wordings * update check extension for wdt configmap * PR fixes * add bypass option for wdt version check * update script for checkDirectoryExtension * update wordings * update wordings * Correct spelling * add bypsss wdt version check wordings
1 parent e3e7369 commit fda0686

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

operator/src/main/resources/scripts/modelInImage.sh

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
source ${SCRIPTPATH}/utils.sh
99

10-
10+
WDT_MINIMUM_VERSION="1.7.3"
1111
INTROSPECTCM_IMAGE_MD5="/weblogic-operator/introspectormii/inventory_image.md5"
1212
INTROSPECTCM_CM_MD5="/weblogic-operator/introspectormii/inventory_cm.md5"
1313
INTROSPECTCM_PASSPHRASE_MD5="/weblogic-operator/introspectormii/inventory_passphrase.md5"
@@ -283,6 +283,11 @@ function createWLDomain() {
283283
checkDirNotExistsOrEmpty ${IMG_MODELS_HOME}
284284
checkDirNotExistsOrEmpty ${WDT_BINDIR}
285285

286+
checkModelDirectoryExtensions
287+
if [ "true" != "${WDT_BYPASS_WDT_VERSION_CHECK}" ] ; then
288+
checkWDTVersion
289+
fi
290+
286291
# copy the filter related files to the wdt lib
287292

288293
cp ${WDT_FILTER_JSON} ${WDT_ROOT}/lib
@@ -384,6 +389,63 @@ function checkDirNotExistsOrEmpty() {
384389
trace "Exiting checkDirNotExistsOrEmpty"
385390
}
386391

392+
# limit the file extensions in the model directories
393+
394+
function checkModelDirectoryExtensions() {
395+
trace "Entering checkModelDirectoryExtensions"
396+
397+
cd ${IMG_MODELS_HOME}
398+
counter=$(ls -I "*.yaml" -I "*.zip" -I "*.properties" | wc -l)
399+
if [ $counter -ne 0 ] ; then
400+
trace SEVERE "Model image directory ${IMG_MODELS_HOME} contains files with unsupported extensions. " \
401+
"Expected extensions: .yaml, .properties, or .zip"
402+
trace SEVERE "Model image directory files with unsupported extensions: " \
403+
"'$(ls -I "*.yaml" -I "*.zip" -I "*.properties")'"
404+
exitOrLoop
405+
fi
406+
if [ -d ${WDT_CONFIGMAP_ROOT} ] ; then
407+
cd ${WDT_CONFIGMAP_ROOT}
408+
counter=$(ls -I "*.yaml" -I "*.properties" | wc -l)
409+
if [ $counter -ne 0 ] ; then
410+
trace SEVERE "Model configmap directory ${WDT_CONFIGMAP_ROOT} contains files with unsupported extensions. " \
411+
"Expected extensions: .yaml or .properties"
412+
trace SEVERE "Model configmap directory files with unsupported extensions: " \
413+
"'$(ls -I "*.yaml" -I "*.properties")'"
414+
exitOrLoop
415+
fi
416+
fi
417+
418+
trace "Exiting checkModelDirectoryExtensions"
419+
}
420+
421+
# Check for WDT version
422+
423+
function checkWDTVersion() {
424+
trace "Entering checkWDTVersion"
425+
unzip -c ${WDT_ROOT}/lib/weblogic-deploy-core.jar META-INF/MANIFEST.MF > /tmp/wdtversion.txt || exitOrLoop
426+
local wdt_version="$(grep "Implementation-Version" /tmp/wdtversion.txt | cut -f2 -d' ' | tr -d '\r' )" || exitOrLoop
427+
if [ ! -z ${wdt_version} ]; then
428+
versionGE ${wdt_version} ${WDT_MINIMUM_VERSION}
429+
if [ $? != "0" ] ; then
430+
trace SEVERE "Domain Source Type is 'FromModel' and it requires WebLogic Deploy Tool with a minimum " \
431+
"version of ${WDT_MINIMUM_VERSION} installed in the image. The version of the WebLogic Deploy Tool installed " \
432+
"in the image is ${wdt_version}, you can create another image with an updated version of the WebLogic Deploy " \
433+
"Tool and redeploy the domain again. To bypass this check, set environment variable " \
434+
"'WDT_BYPASS_WDT_VERSION_CHECK' to 'true'"
435+
exitOrLoop
436+
fi
437+
else
438+
trace SEVERE "Domain Source Type is 'FromModel' and it requires WebLogic Deploy Tool with a minimum " \
439+
"version of ${WDT_MINIMUM_VERSION} installed in the image. The version of the WebLogic Deploy Tool installed " \
440+
"in the image cannot be determined, you can create another image with an updated version of the WebLogic Deploy" \
441+
" Tool and redeploy the domain again. To bypass this check, set environment variable " \
442+
"'WDT_BYPASS_WDT_VERSION_CHECK' to 'true'"
443+
exitOrLoop
444+
fi
445+
446+
trace "Exiting checkWDTVersion"
447+
}
448+
387449
# getSecretsMD5
388450
#
389451
# concatenate all the secrets, calculate the md5 and delete the file.

0 commit comments

Comments
 (0)