@@ -86,7 +86,7 @@ function validatePersistentVolumeClaimName {
8686#
8787# Function to validate the persistent volume name
8888#
89- function validatePersistenVolumeName {
89+ function validatePersistentVolumeName {
9090 validateLowerCase ${persistenceVolumeName} " persistenceVolumeName"
9191
9292 if [[ ${persistenceVolumeName} != ${domainUid} -* ]] ; then
@@ -96,6 +96,17 @@ function validatePersistenVolumeName {
9696 fi
9797}
9898
99+ #
100+ # Function to validate the persistence type
101+ #
102+ function validatePersistenceType {
103+ if [ ${persistenceType} == " nfs" ] ; then
104+ validateInputParamsSpecified nfsServer
105+ elif [ ${persistenceType} != " hostPath" ] ; then
106+ validationError " The persistenceType ${persistenceType} is invalid, it must be hostPath or nfs"
107+ fi
108+ }
109+
99110#
100111# Function to validate the secret name
101112#
@@ -262,7 +273,8 @@ function initialize {
262273 validateDomainUid
263274 validateClusterName
264275 validateStorageClass
265- validatePersistenVolumeName
276+ validatePersistenceType
277+ validatePersistentVolumeName
266278 validatePersistentVolumeClaimName
267279 validateSecretName
268280 validateImagePullSecretName
@@ -283,12 +295,22 @@ function createYamlFiles {
283295 echo Generating ${pvOutput}
284296
285297 cp ${pvInput} ${pvOutput}
298+ if [ " ${persistenceType} " == " nfs" ]; then
299+ hostPathPrefix=" ${disabledPrefix} "
300+ nfsPrefix=" ${enabledPrefix} "
301+ sed -i -e " s:%NFS_SERVER%:${nfsServer} :g" ${pvOutput}
302+ else
303+ hostPathPrefix=" ${enabledPrefix} "
304+ nfsPrefix=" ${disabledPrefix} "
305+ fi
286306 sed -i -e " s:%DOMAIN_UID%:${domainUid} :g" ${pvOutput}
287307 sed -i -e " s:%NAMESPACE%:$namespace :g" ${pvOutput}
288308 sed -i -e " s:%PERSISTENT_VOLUME%:${persistenceVolumeName} :g" ${pvOutput}
289309 sed -i -e " s:%PERSISTENT_VOLUME_PATH%:${persistencePath} :g" ${pvOutput}
290310 sed -i -e " s:%PERSISTENT_VOLUME_SIZE%:${persistenceSize} :g" ${pvOutput}
291311 sed -i -e " s:%STORAGE_CLASS_NAME%:${persistenceStorageClass} :g" ${pvOutput}
312+ sed -i -e " s:%HOST_PATH_PREFIX%:${hostPathPrefix} :g" ${pvOutput}
313+ sed -i -e " s:%NFS_PREFIX%:${nfsPrefix} :g" ${pvOutput}
292314
293315 # Generate the yaml to create the persistent volume claim
294316 echo Generating ${pvcOutput}
0 commit comments