@@ -86,7 +86,7 @@ function validatePersistentVolumeClaimName {
86
86
#
87
87
# Function to validate the persistent volume name
88
88
#
89
- function validatePersistenVolumeName {
89
+ function validatePersistentVolumeName {
90
90
validateLowerCase ${persistenceVolumeName} " persistenceVolumeName"
91
91
92
92
if [[ ${persistenceVolumeName} != ${domainUid} -* ]] ; then
@@ -96,6 +96,17 @@ function validatePersistenVolumeName {
96
96
fi
97
97
}
98
98
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
+
99
110
#
100
111
# Function to validate the secret name
101
112
#
@@ -262,7 +273,8 @@ function initialize {
262
273
validateDomainUid
263
274
validateClusterName
264
275
validateStorageClass
265
- validatePersistenVolumeName
276
+ validatePersistenceType
277
+ validatePersistentVolumeName
266
278
validatePersistentVolumeClaimName
267
279
validateSecretName
268
280
validateImagePullSecretName
@@ -283,12 +295,22 @@ function createYamlFiles {
283
295
echo Generating ${pvOutput}
284
296
285
297
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
286
306
sed -i -e " s:%DOMAIN_UID%:${domainUid} :g" ${pvOutput}
287
307
sed -i -e " s:%NAMESPACE%:$namespace :g" ${pvOutput}
288
308
sed -i -e " s:%PERSISTENT_VOLUME%:${persistenceVolumeName} :g" ${pvOutput}
289
309
sed -i -e " s:%PERSISTENT_VOLUME_PATH%:${persistencePath} :g" ${pvOutput}
290
310
sed -i -e " s:%PERSISTENT_VOLUME_SIZE%:${persistenceSize} :g" ${pvOutput}
291
311
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}
292
314
293
315
# Generate the yaml to create the persistent volume claim
294
316
echo Generating ${pvcOutput}
0 commit comments