mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Job: Use generic sets to avoid unnecessary string casts in valiations
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
This commit is contained in:
		@@ -28,6 +28,7 @@ import (
 | 
				
			|||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
	unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
 | 
						unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/labels"
 | 
						"k8s.io/apimachinery/pkg/labels"
 | 
				
			||||||
 | 
						"k8s.io/apimachinery/pkg/types"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/sets"
 | 
						"k8s.io/apimachinery/pkg/util/sets"
 | 
				
			||||||
	apimachineryvalidation "k8s.io/apimachinery/pkg/util/validation"
 | 
						apimachineryvalidation "k8s.io/apimachinery/pkg/util/validation"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/validation/field"
 | 
						"k8s.io/apimachinery/pkg/util/validation/field"
 | 
				
			||||||
@@ -402,25 +403,25 @@ func validateJobStatus(status *batch.JobStatus, fldPath *field.Path) field.Error
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	if status.UncountedTerminatedPods != nil {
 | 
						if status.UncountedTerminatedPods != nil {
 | 
				
			||||||
		path := fldPath.Child("uncountedTerminatedPods")
 | 
							path := fldPath.Child("uncountedTerminatedPods")
 | 
				
			||||||
		seen := sets.NewString()
 | 
							seen := sets.New[types.UID]()
 | 
				
			||||||
		for i, k := range status.UncountedTerminatedPods.Succeeded {
 | 
							for i, k := range status.UncountedTerminatedPods.Succeeded {
 | 
				
			||||||
			p := path.Child("succeeded").Index(i)
 | 
								p := path.Child("succeeded").Index(i)
 | 
				
			||||||
			if k == "" {
 | 
								if k == "" {
 | 
				
			||||||
				allErrs = append(allErrs, field.Invalid(p, k, "must not be empty"))
 | 
									allErrs = append(allErrs, field.Invalid(p, k, "must not be empty"))
 | 
				
			||||||
			} else if seen.Has(string(k)) {
 | 
								} else if seen.Has(k) {
 | 
				
			||||||
				allErrs = append(allErrs, field.Duplicate(p, k))
 | 
									allErrs = append(allErrs, field.Duplicate(p, k))
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				seen.Insert(string(k))
 | 
									seen.Insert(k)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for i, k := range status.UncountedTerminatedPods.Failed {
 | 
							for i, k := range status.UncountedTerminatedPods.Failed {
 | 
				
			||||||
			p := path.Child("failed").Index(i)
 | 
								p := path.Child("failed").Index(i)
 | 
				
			||||||
			if k == "" {
 | 
								if k == "" {
 | 
				
			||||||
				allErrs = append(allErrs, field.Invalid(p, k, "must not be empty"))
 | 
									allErrs = append(allErrs, field.Invalid(p, k, "must not be empty"))
 | 
				
			||||||
			} else if seen.Has(string(k)) {
 | 
								} else if seen.Has(k) {
 | 
				
			||||||
				allErrs = append(allErrs, field.Duplicate(p, k))
 | 
									allErrs = append(allErrs, field.Duplicate(p, k))
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				seen.Insert(string(k))
 | 
									seen.Insert(k)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user