@@ -1770,8 +1770,7 @@ func ValidatePersistentVolume(pv *core.PersistentVolume) field.ErrorList {
1770
1770
// ValidatePersistentVolumeUpdate tests to see if the update is legal for an end user to make.
1771
1771
// newPv is updated with fields that cannot be changed.
1772
1772
func ValidatePersistentVolumeUpdate (newPv , oldPv * core.PersistentVolume ) field.ErrorList {
1773
- allErrs := field.ErrorList {}
1774
- allErrs = ValidatePersistentVolume (newPv )
1773
+ allErrs := ValidatePersistentVolume (newPv )
1775
1774
1776
1775
// PersistentVolumeSource should be immutable after creation.
1777
1776
if ! apiequality .Semantic .DeepEqual (newPv .Spec .PersistentVolumeSource , oldPv .Spec .PersistentVolumeSource ) {
@@ -2293,46 +2292,44 @@ func ValidateVolumeDevices(devices []core.VolumeDevice, volmounts map[string]str
2293
2292
devicepath := sets .NewString ()
2294
2293
devicename := sets .NewString ()
2295
2294
2296
- if devices != nil {
2297
- for i , dev := range devices {
2298
- idxPath := fldPath .Index (i )
2299
- devName := dev .Name
2300
- devPath := dev .DevicePath
2301
- didMatch , isPVC := isMatchedDevice (devName , volumes )
2302
- if len (devName ) == 0 {
2303
- allErrs = append (allErrs , field .Required (idxPath .Child ("name" ), "" ))
2304
- }
2305
- if devicename .Has (devName ) {
2306
- allErrs = append (allErrs , field .Invalid (idxPath .Child ("name" ), devName , "must be unique" ))
2307
- }
2308
- // Must be PersistentVolumeClaim volume source
2309
- if didMatch && ! isPVC {
2310
- allErrs = append (allErrs , field .Invalid (idxPath .Child ("name" ), devName , "can only use volume source type of PersistentVolumeClaim for block mode" ))
2311
- }
2312
- if ! didMatch {
2313
- allErrs = append (allErrs , field .NotFound (idxPath .Child ("name" ), devName ))
2314
- }
2315
- if len (devPath ) == 0 {
2316
- allErrs = append (allErrs , field .Required (idxPath .Child ("devicePath" ), "" ))
2317
- }
2318
- if devicepath .Has (devPath ) {
2319
- allErrs = append (allErrs , field .Invalid (idxPath .Child ("devicePath" ), devPath , "must be unique" ))
2320
- }
2321
- if len (devPath ) > 0 && len (validatePathNoBacksteps (devPath , fldPath .Child ("devicePath" ))) > 0 {
2322
- allErrs = append (allErrs , field .Invalid (idxPath .Child ("devicePath" ), devPath , "can not contain backsteps ('..')" ))
2323
- } else {
2324
- devicepath .Insert (devPath )
2325
- }
2326
- // check for overlap with VolumeMount
2327
- if deviceNameAlreadyExists (devName , volmounts ) {
2328
- allErrs = append (allErrs , field .Invalid (idxPath .Child ("name" ), devName , "must not already exist in volumeMounts" ))
2329
- }
2330
- if devicePathAlreadyExists (devPath , volmounts ) {
2331
- allErrs = append (allErrs , field .Invalid (idxPath .Child ("devicePath" ), devPath , "must not already exist as a path in volumeMounts" ))
2332
- }
2333
- if len (devName ) > 0 {
2334
- devicename .Insert (devName )
2335
- }
2295
+ for i , dev := range devices {
2296
+ idxPath := fldPath .Index (i )
2297
+ devName := dev .Name
2298
+ devPath := dev .DevicePath
2299
+ didMatch , isPVC := isMatchedDevice (devName , volumes )
2300
+ if len (devName ) == 0 {
2301
+ allErrs = append (allErrs , field .Required (idxPath .Child ("name" ), "" ))
2302
+ }
2303
+ if devicename .Has (devName ) {
2304
+ allErrs = append (allErrs , field .Invalid (idxPath .Child ("name" ), devName , "must be unique" ))
2305
+ }
2306
+ // Must be PersistentVolumeClaim volume source
2307
+ if didMatch && ! isPVC {
2308
+ allErrs = append (allErrs , field .Invalid (idxPath .Child ("name" ), devName , "can only use volume source type of PersistentVolumeClaim for block mode" ))
2309
+ }
2310
+ if ! didMatch {
2311
+ allErrs = append (allErrs , field .NotFound (idxPath .Child ("name" ), devName ))
2312
+ }
2313
+ if len (devPath ) == 0 {
2314
+ allErrs = append (allErrs , field .Required (idxPath .Child ("devicePath" ), "" ))
2315
+ }
2316
+ if devicepath .Has (devPath ) {
2317
+ allErrs = append (allErrs , field .Invalid (idxPath .Child ("devicePath" ), devPath , "must be unique" ))
2318
+ }
2319
+ if len (devPath ) > 0 && len (validatePathNoBacksteps (devPath , fldPath .Child ("devicePath" ))) > 0 {
2320
+ allErrs = append (allErrs , field .Invalid (idxPath .Child ("devicePath" ), devPath , "can not contain backsteps ('..')" ))
2321
+ } else {
2322
+ devicepath .Insert (devPath )
2323
+ }
2324
+ // check for overlap with VolumeMount
2325
+ if deviceNameAlreadyExists (devName , volmounts ) {
2326
+ allErrs = append (allErrs , field .Invalid (idxPath .Child ("name" ), devName , "must not already exist in volumeMounts" ))
2327
+ }
2328
+ if devicePathAlreadyExists (devPath , volmounts ) {
2329
+ allErrs = append (allErrs , field .Invalid (idxPath .Child ("devicePath" ), devPath , "must not already exist as a path in volumeMounts" ))
2330
+ }
2331
+ if len (devName ) > 0 {
2332
+ devicename .Insert (devName )
2336
2333
}
2337
2334
}
2338
2335
return allErrs
@@ -3186,7 +3183,7 @@ func validatePreferAvoidPodsEntry(avoidPodEntry core.PreferAvoidPodsEntry, fldPa
3186
3183
if avoidPodEntry .PodSignature .PodController == nil {
3187
3184
allErrors = append (allErrors , field .Required (fldPath .Child ("PodSignature" ), "" ))
3188
3185
} else {
3189
- if * (avoidPodEntry .PodSignature .PodController .Controller ) != true {
3186
+ if ! * (avoidPodEntry .PodSignature .PodController .Controller ) {
3190
3187
allErrors = append (allErrors ,
3191
3188
field .Invalid (fldPath .Child ("PodSignature" ).Child ("PodController" ).Child ("Controller" ),
3192
3189
* (avoidPodEntry .PodSignature .PodController .Controller ), "must point to a controller" ))
0 commit comments