Refactor GlusterFS PV spec.
This patch introduces glusterfsPersistentVolumeSource addition to glusterfsVolumeSource. All fields remains same as glusterfsVolumeSource with an addition of a new field called `EndpointsNamespace` to define namespace of endpoint in the spec. Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
@@ -903,6 +903,26 @@ func validateGlusterfsVolumeSource(glusterfs *core.GlusterfsVolumeSource, fldPat
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
func validateGlusterfsPersistentVolumeSource(glusterfs *core.GlusterfsPersistentVolumeSource, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if len(glusterfs.EndpointsName) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("endpoints"), ""))
|
||||
}
|
||||
if len(glusterfs.Path) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("path"), ""))
|
||||
}
|
||||
if glusterfs.EndpointsNamespace != nil {
|
||||
endpointNs := glusterfs.EndpointsNamespace
|
||||
if *endpointNs == "" {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("endpointsNamespace"), *endpointNs, "if the endpointnamespace is set, it must be a valid namespace name"))
|
||||
} else {
|
||||
for _, msg := range ValidateNamespaceName(*endpointNs, false) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("endpointsNamespace"), *endpointNs, msg))
|
||||
}
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateFlockerVolumeSource(flocker *core.FlockerVolumeSource, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
@@ -1567,7 +1587,7 @@ func ValidatePersistentVolume(pv *core.PersistentVolume) field.ErrorList {
|
||||
allErrs = append(allErrs, field.Forbidden(specPath.Child("glusterfs"), "may not specify more than 1 volume type"))
|
||||
} else {
|
||||
numVolumes++
|
||||
allErrs = append(allErrs, validateGlusterfsVolumeSource(pv.Spec.Glusterfs, specPath.Child("glusterfs"))...)
|
||||
allErrs = append(allErrs, validateGlusterfsPersistentVolumeSource(pv.Spec.Glusterfs, specPath.Child("glusterfs"))...)
|
||||
}
|
||||
}
|
||||
if pv.Spec.Flocker != nil {
|
||||
|
Reference in New Issue
Block a user