Validate that volume mountpoints are unique

This commit is contained in:
Paul Morie
2016-03-17 23:52:34 -04:00
parent 6cd8e5c0e6
commit 24aade64f5
2 changed files with 12 additions and 6 deletions

View File

@@ -1107,6 +1107,7 @@ func validateSecretKeySelector(s *api.SecretKeySelector, fldPath *field.Path) fi
func validateVolumeMounts(mounts []api.VolumeMount, volumes sets.String, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
mountpoints := sets.NewString()
for i, mnt := range mounts {
idxPath := fldPath.Index(i)
@@ -1120,6 +1121,10 @@ func validateVolumeMounts(mounts []api.VolumeMount, volumes sets.String, fldPath
} else if strings.Contains(mnt.MountPath, ":") {
allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must not contain ':'"))
}
if mountpoints.Has(mnt.MountPath) {
allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must be unique"))
}
mountpoints.Insert(mnt.MountPath)
}
return allErrs
}