mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 05:40:42 +00:00 
			
		
		
		
	Add extra value validation for matchExpression field in LabelSelector
This commit is contained in:
		
				
					committed by
					
						 Jordan Liggitt
						Jordan Liggitt
					
				
			
			
				
	
			
			
			
						parent
						
							aa66cec6fa
						
					
				
				
					commit
					0843c4dfca
				
			| @@ -146,11 +146,13 @@ func hasJobTrackingAnnotation(job *batch.Job) bool { | ||||
| // ValidateJobSpec validates a JobSpec and returns an ErrorList with any errors. | ||||
| func ValidateJobSpec(spec *batch.JobSpec, fldPath *field.Path, opts apivalidation.PodValidationOptions) field.ErrorList { | ||||
| 	allErrs := validateJobSpec(spec, fldPath, opts) | ||||
|  | ||||
| 	labelSelectorValidationOpts := unversionedvalidation.LabelSelectorValidationOptions{ | ||||
| 		AllowInvalidLabelValueInSelector: opts.AllowInvalidLabelValueInSelector, | ||||
| 	} | ||||
| 	if spec.Selector == nil { | ||||
| 		allErrs = append(allErrs, field.Required(fldPath.Child("selector"), "")) | ||||
| 	} else { | ||||
| 		allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...) | ||||
| 		allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(spec.Selector, labelSelectorValidationOpts, fldPath.Child("selector"))...) | ||||
| 	} | ||||
|  | ||||
| 	// Whether manually or automatically generated, the selector of the job must match the pods it will produce. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user